Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove experimental tracing #947

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 6 additions & 60 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions buildpacks/nodejs-corepack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Removed

- Removed experimental OpenTelemetry tracing added
in [#652](https://github.com/heroku/buildpacks-nodejs/pull/652) ([#947](https://github.com/heroku/buildpacks-nodejs/pull/947))

## [3.2.15] - 2024-10-04

- No changes.
Expand Down
1 change: 0 additions & 1 deletion buildpacks/nodejs-corepack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ heroku-nodejs-utils.workspace = true
indoc = "2"
libcnb = { version = "=0.23.0", features = ["trace"] }
libherokubuildpack = { version = "=0.23.0", default-features = false, features = ["log"] }
opentelemetry = "0.24"
serde = "1"
thiserror = "1"

Expand Down
93 changes: 37 additions & 56 deletions buildpacks/nodejs-corepack/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use heroku_nodejs_utils::package_json::{PackageJson, PackageJsonError};
use heroku_nodejs_utils::telemetry::init_tracer;
use libcnb::build::{BuildContext, BuildResult, BuildResultBuilder};
use libcnb::data::build_plan::BuildPlanBuilder;
use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder};
use libcnb::generic::GenericMetadata;
use libcnb::generic::GenericPlatform;
use libcnb::{buildpack_main, Buildpack, Env};
use libherokubuildpack::log::log_header;
use opentelemetry::trace::{TraceContextExt, Tracer};
use opentelemetry::KeyValue;

use crate::enable_corepack::enable_corepack;
use crate::prepare_corepack::prepare_corepack;
Expand All @@ -35,67 +32,51 @@ impl Buildpack for CorepackBuildpack {
type Error = CorepackBuildpackError;

fn detect(&self, context: DetectContext<Self>) -> libcnb::Result<DetectResult, Self::Error> {
let tracer = init_tracer(context.buildpack_descriptor.buildpack.id.to_string());
tracer.in_span("nodejs-corepack-detect", |_cx| {
// Corepack requires the `packageManager` key from `package.json`.
// This buildpack won't be detected without it.
let pkg_json_path = context.app_dir.join("package.json");
if pkg_json_path.exists() {
let pkg_json = PackageJson::read(pkg_json_path)
.map_err(CorepackBuildpackError::PackageJson)?;
cfg::get_supported_package_manager(&pkg_json).map_or_else(
|| DetectResultBuilder::fail().build(),
|pkg_mgr| {
DetectResultBuilder::pass()
.build_plan(
BuildPlanBuilder::new()
.requires("node")
.requires(&pkg_mgr)
.provides(pkg_mgr)
.build(),
)
.build()
},
)
} else {
DetectResultBuilder::fail().build()
}
})
// Corepack requires the `packageManager` key from `package.json`.
// This buildpack won't be detected without it.
let pkg_json_path = context.app_dir.join("package.json");
if pkg_json_path.exists() {
let pkg_json =
PackageJson::read(pkg_json_path).map_err(CorepackBuildpackError::PackageJson)?;
cfg::get_supported_package_manager(&pkg_json).map_or_else(
|| DetectResultBuilder::fail().build(),
|pkg_mgr| {
DetectResultBuilder::pass()
.build_plan(
BuildPlanBuilder::new()
.requires("node")
.requires(&pkg_mgr)
.provides(pkg_mgr)
.build(),
)
.build()
},
)
} else {
DetectResultBuilder::fail().build()
}
}

fn build(&self, context: BuildContext<Self>) -> libcnb::Result<BuildResult, Self::Error> {
let tracer = init_tracer(context.buildpack_descriptor.buildpack.id.to_string());
tracer.in_span("nodejs-corepack-build", |cx| {
let pkg_mgr = PackageJson::read(context.app_dir.join("package.json"))
.map_err(CorepackBuildpackError::PackageJson)?
.package_manager
.ok_or(CorepackBuildpackError::PackageManagerMissing)?;
let pkg_mgr = PackageJson::read(context.app_dir.join("package.json"))
.map_err(CorepackBuildpackError::PackageJson)?
.package_manager
.ok_or(CorepackBuildpackError::PackageManagerMissing)?;

cx.span().set_attributes([
KeyValue::new("package_manager.name", pkg_mgr.name.clone()),
KeyValue::new("package_manager.version", pkg_mgr.version.to_string()),
]);
let env = &Env::from_current();

let env = &Env::from_current();
let corepack_version =
cmd::corepack_version(env).map_err(CorepackBuildpackError::CorepackVersion)?;

let corepack_version =
cmd::corepack_version(env).map_err(CorepackBuildpackError::CorepackVersion)?;
log_header(format!(
"Installing {} {} via corepack {corepack_version}",
pkg_mgr.name, pkg_mgr.version
));

cx.span().set_attribute(KeyValue::new(
"corepack.version",
corepack_version.to_string(),
));
enable_corepack(&context, &corepack_version, &pkg_mgr, env)?;
prepare_corepack(&context, &pkg_mgr, env)?;

log_header(format!(
"Installing {} {} via corepack {corepack_version}",
pkg_mgr.name, pkg_mgr.version
));

enable_corepack(&context, &corepack_version, &pkg_mgr, env)?;
prepare_corepack(&context, &pkg_mgr, env)?;

BuildResultBuilder::new().build()
})
BuildResultBuilder::new().build()
}

fn on_error(&self, err: libcnb::Error<Self::Error>) {
Expand Down
3 changes: 0 additions & 3 deletions common/nodejs-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ indoc = "2"
keep_a_changelog_file = "0.1.0"
libcnb-data = "=0.23.0"
node-semver = "2"
opentelemetry = "0.24"
opentelemetry_sdk = { version = "0.24", features = ["trace"] }
opentelemetry-stdout = { version = "0.5", features = ["trace"] }
regex = "1"
serde = { version = "1", features = ['derive'] }
serde_json = "1"
Expand Down
1 change: 0 additions & 1 deletion common/nodejs-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ mod npmjs_org;
pub mod package_json;
pub mod package_manager;
mod s3;
pub mod telemetry;
pub mod vrs;
82 changes: 0 additions & 82 deletions common/nodejs-utils/src/telemetry.rs

This file was deleted.