File tree 2 files changed +9
-20
lines changed
2 files changed +9
-20
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ use tracing_subscriber::util::SubscriberInitExt;
20
20
#[ cfg( feature = "test" ) ]
21
21
use tracing_subscriber:: { EnvFilter , Registry , reload:: Handle } ;
22
22
23
+ #[ cfg( all( feature = "test" , feature = "otel" ) ) ]
24
+ use crate :: cli:: log;
25
+
23
26
pub mod filesource;
24
27
pub mod terminalsource;
25
28
@@ -180,7 +183,10 @@ impl Default for OsProcess {
180
183
pub struct TestProcess {
181
184
pub process : Process ,
182
185
pub console_filter : Handle < EnvFilter , Registry > ,
183
- _tracing_guard : DefaultGuard , // guard is dropped at the end of the test
186
+ // These guards are dropped _in order_ at the end of the test.
187
+ #[ cfg( feature = "otel" ) ]
188
+ _telemetry_guard : log:: GlobalTelemetryGuard ,
189
+ _tracing_guard : DefaultGuard ,
184
190
}
185
191
186
192
#[ cfg( feature = "test" ) ]
@@ -237,6 +243,8 @@ impl From<TestContext> for TestProcess {
237
243
Self {
238
244
process : inner,
239
245
console_filter,
246
+ #[ cfg( feature = "otel" ) ]
247
+ _telemetry_guard : log:: set_global_telemetry ( ) ,
240
248
_tracing_guard : tracing_subscriber. set_default ( ) ,
241
249
}
242
250
}
Original file line number Diff line number Diff line change @@ -231,22 +231,3 @@ where
231
231
let rustup_home = RustupHome :: new_in ( test_dir) ?;
232
232
f ( & rustup_home)
233
233
}
234
-
235
- pub async fn before_test_async ( ) {
236
- #[ cfg( feature = "otel" ) ]
237
- {
238
- opentelemetry:: global:: set_text_map_propagator (
239
- opentelemetry_sdk:: propagation:: TraceContextPropagator :: new ( ) ,
240
- ) ;
241
- }
242
- }
243
-
244
- pub async fn after_test_async ( ) {
245
- #[ cfg( feature = "otel" ) ]
246
- {
247
- // We're tracing, so block until all spans are exported.
248
- opentelemetry:: global:: set_tracer_provider (
249
- opentelemetry:: trace:: noop:: NoopTracerProvider :: new ( ) ,
250
- ) ;
251
- }
252
- }
You can’t perform that action at this time.
0 commit comments