Skip to content

Commit

Permalink
refactor(log): replace the TELEMETRY_DEFAULT_TARCER singleton with …
Browse files Browse the repository at this point in the history
…a function
  • Loading branch information
rami3l committed Jun 18, 2024
1 parent 618e072 commit 2261e26
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/cli/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use tracing_subscriber::{
EnvFilter, Layer,
};

#[cfg(feature = "otel")]
use once_cell::sync::Lazy;
#[cfg(feature = "otel")]
use opentelemetry_sdk::trace::Tracer;

Expand Down Expand Up @@ -131,16 +129,16 @@ where
EnvFilter::new("rustup=TRACE")
};
tracing_opentelemetry::layer()
.with_tracer(TELEMETRY_DEFAULT_TRACER.clone())
.with_tracer(telemetry_default_tracer())
.with_filter(env_filter)
}

/// The default `opentelemetry` tracer used across Rustup.
///
/// # Note
/// The initializer function will panic if not called within the context of a [`tokio`] runtime.
/// This function will panic if not called within the context of a [`tokio`] runtime.
#[cfg(feature = "otel")]
static TELEMETRY_DEFAULT_TRACER: Lazy<Tracer> = Lazy::new(|| {
fn telemetry_default_tracer() -> Tracer {
use std::time::Duration;

use opentelemetry::KeyValue;
Expand All @@ -164,4 +162,4 @@ static TELEMETRY_DEFAULT_TRACER: Lazy<Tracer> = Lazy::new(|| {
)
.install_batch(opentelemetry_sdk::runtime::Tokio)
.expect("error installing `OtlpTracePipeline` in the current `tokio` runtime")
});
}

0 comments on commit 2261e26

Please sign in to comment.