Skip to content

Commit

Permalink
Remove experimental tracing
Browse files Browse the repository at this point in the history
Removes the otel tracing added in [#652](#652) which was introduced before the `libcnb` tracing support in [heroku/libcnb.rs#723](heroku/libcnb.rs#723).

This is also blocking the dependency updates in [#942](#942).
  • Loading branch information
colincasey committed Oct 28, 2024
1 parent 0b9fc8c commit cf0ce68
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 203 deletions.
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.

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.

0 comments on commit cf0ce68

Please sign in to comment.