Skip to content

Commit

Permalink
Global error handler cleanup - trace API (#2252)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Oct 26, 2024
1 parent 4c7bf58 commit 9382bfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions opentelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ futures-sink = "0.3"
once_cell = { workspace = true }
pin-project-lite = { workspace = true, optional = true }
thiserror = { workspace = true }
tracing = {workspace = true, optional = true} # optional for opentelemetry internal logging

[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
js-sys = "0.3.63"
Expand All @@ -38,6 +39,7 @@ testing = ["trace", "metrics"]
logs = []
logs_level_enabled = ["logs"]
otel_unstable = []
internal-logs = ["tracing"]

[dev-dependencies]
opentelemetry_sdk = { path = "../opentelemetry-sdk", features = ["logs_level_enabled"]} # for documentation tests
Expand Down
10 changes: 8 additions & 2 deletions opentelemetry/src/trace/context.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Context extensions for tracing
use crate::{
global,
global, otel_debug,
trace::{Span, SpanContext, Status},
Context, ContextGuard, KeyValue,
};
Expand Down Expand Up @@ -55,7 +55,13 @@ impl SpanRef<'_> {
if let Some(ref inner) = self.0.inner {
match inner.lock() {
Ok(mut locked) => f(&mut locked),
Err(err) => global::handle_error(err),
Err(err) => {
otel_debug!(
name: "SpanRef.LockFailed",
message = "Failed to acquire lock for SpanRef: {:?}",
reason = format!("{:?}", err),
span_context = format!("{:?}", self.0.span_context));
}
}
}
}
Expand Down

0 comments on commit 9382bfb

Please sign in to comment.