Skip to content

Commit 2261e26

Browse files
committed
refactor(log): replace the TELEMETRY_DEFAULT_TARCER singleton with a function
1 parent 618e072 commit 2261e26

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/cli/log.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use tracing_subscriber::{
1111
EnvFilter, Layer,
1212
};
1313

14-
#[cfg(feature = "otel")]
15-
use once_cell::sync::Lazy;
1614
#[cfg(feature = "otel")]
1715
use opentelemetry_sdk::trace::Tracer;
1816

@@ -131,16 +129,16 @@ where
131129
EnvFilter::new("rustup=TRACE")
132130
};
133131
tracing_opentelemetry::layer()
134-
.with_tracer(TELEMETRY_DEFAULT_TRACER.clone())
132+
.with_tracer(telemetry_default_tracer())
135133
.with_filter(env_filter)
136134
}
137135

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

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

0 commit comments

Comments
 (0)