Skip to content

Commit

Permalink
Update to opentelemetry 0.24
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Feb 4, 2025
1 parent b9d14a5 commit fc13411
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 10 additions & 4 deletions libcnb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ include = ["src/**/*", "LICENSE", "README.md"]
workspace = true

[features]
trace = ["dep:opentelemetry", "dep:opentelemetry_sdk", "dep:opentelemetry-stdout"]
trace = [
"dep:opentelemetry",
"dep:opentelemetry_sdk",
"dep:opentelemetry-stdout",
]

[dependencies]
anyhow = { version = "1.0.94", optional = true }
cyclonedx-bom = { version = "0.8.0", optional = true }
libcnb-common.workspace = true
libcnb-data.workspace = true
libcnb-proc-macros.workspace = true
opentelemetry = { version = "0.21.0", optional = true }
opentelemetry_sdk = { version = "0.21.2", optional = true }
opentelemetry-stdout = { version = "0.2.0", optional = true, features = ["trace"] }
opentelemetry = { version = "0.24", optional = true }
opentelemetry_sdk = { version = "0.24", optional = true }
opentelemetry-stdout = { version = "0.5", optional = true, features = [
"trace",
] }
serde = { version = "1.0.215", features = ["derive"] }
thiserror = "2.0.6"
toml.workspace = true
Expand Down
12 changes: 5 additions & 7 deletions libcnb/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ pub(crate) fn start_trace(buildpack: &Buildpack, phase_name: &'static str) -> Bu
// Get a tracer identified by the instrumentation scope/library. The libcnb
// crate name/version seems to map well to the suggestion here:
// https://opentelemetry.io/docs/specs/otel/trace/api/#get-a-tracer.
let tracer = provider.versioned_tracer(
env!("CARGO_PKG_NAME"),
Some(env!("CARGO_PKG_VERSION")),
None as Option<&str>,
None,
);
let tracer = provider
.tracer_builder(env!("CARGO_PKG_NAME"))
.with_version(env!("CARGO_PKG_VERSION"))
.build();

let mut span = tracer.start(trace_name);
span.set_attributes([
Expand Down Expand Up @@ -190,6 +188,6 @@ mod tests {
// Check error status
assert!(tracing_contents
.contains("\"message\":\"Custom { kind: Other, error: \\\"it's broken\\\" }"));
assert!(tracing_contents.contains("\"code\":1"));
assert!(tracing_contents.contains("\"code\":2"));
}
}

0 comments on commit fc13411

Please sign in to comment.