Skip to content

Commit 54f078c

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! refactor(log): reimplement log using tracing
1 parent 653f8cc commit 54f078c

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/test.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ use once_cell::sync::Lazy;
228228

229229
/// A tokio runtime for the sync tests, permitting the use of tracing. This is
230230
/// never shutdown, instead it is just dropped at end of process.
231+
#[cfg(feature = "otel")]
231232
static TRACE_RUNTIME: Lazy<tokio::runtime::Runtime> =
232233
Lazy::new(|| tokio::runtime::Runtime::new().unwrap());
233234

@@ -239,16 +240,13 @@ type Tracer = ();
239240

240241
/// A tracer for the tests.
241242
pub(crate) static TRACER: Lazy<Tracer> = Lazy::new(|| {
242-
use tracing_subscriber::Registry;
243-
244243
#[cfg(feature = "otel")]
245244
{
246-
use crate::cli::log::{telemetry, telemetry_default_tracer};
245+
use crate::cli::log::telemetry_default_tracer;
247246

248247
use opentelemetry::global;
249248
use opentelemetry_sdk::propagation::TraceContextPropagator;
250249
use tokio::runtime::Handle;
251-
use tracing_subscriber::layer::SubscriberExt as _;
252250

253251
// Use the current runtime, or the sync test runtime otherwise.
254252
let handle = match Handle::try_current() {
@@ -259,16 +257,7 @@ pub(crate) static TRACER: Lazy<Tracer> = Lazy::new(|| {
259257
let _guard = handle.enter();
260258

261259
global::set_text_map_propagator(TraceContextPropagator::new());
262-
let tracer = telemetry_default_tracer().unwrap();
263-
let telemetry = telemetry(tracer.clone());
264-
let subscriber = Registry::default().with(telemetry);
265-
tracing::subscriber::set_global_default(subscriber).unwrap();
266-
tracer
267-
}
268-
#[cfg(not(feature = "otel"))]
269-
{
270-
let subscriber = Registry::default();
271-
tracing::subscriber::set_global_default(subscriber).unwrap();
260+
telemetry_default_tracer().unwrap()
272261
}
273262
});
274263

0 commit comments

Comments
 (0)