Skip to content

Commit e919914

Browse files
committed
refactor(test): clean up before_test_async()
1 parent 7d18f92 commit e919914

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

rustup-macros/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn test_inner(mod_path: String, mut input: ItemFn) -> syn::Result<TokenStream> {
9595
let name = input.sig.ident.clone();
9696
let new_block: Block = parse_quote! {
9797
{
98-
let _guard = #before_ident().await;
98+
#before_ident().await;
9999
// Define a function with same name we can instrument inside the
100100
// tracing enablement logic.
101101
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
@@ -118,7 +118,6 @@ fn test_inner(mod_path: String, mut input: ItemFn) -> syn::Result<TokenStream> {
118118
input.block = Box::new(new_block);
119119

120120
Ok(quote! {
121-
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
122121
#[::tokio::test(flavor = "multi_thread", worker_threads = 1)]
123122
#input
124123
})

src/test.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,12 @@ where
224224
f(&rustup_home)
225225
}
226226

227-
pub async fn before_test_async() -> Option<tracing::dispatcher::DefaultGuard> {
227+
pub async fn before_test_async() {
228228
#[cfg(feature = "otel")]
229229
{
230-
use tracing_subscriber::{layer::SubscriberExt, Registry};
231-
232-
let telemetry = {
233-
use opentelemetry::global;
234-
use opentelemetry_sdk::propagation::TraceContextPropagator;
235-
236-
global::set_text_map_propagator(TraceContextPropagator::new());
237-
crate::cli::log::telemetry()
238-
};
239-
240-
let subscriber = Registry::default().with(telemetry);
241-
Some(tracing::subscriber::set_default(subscriber))
242-
}
243-
#[cfg(not(feature = "otel"))]
244-
{
245-
None
230+
opentelemetry::global::set_text_map_propagator(
231+
opentelemetry_sdk::propagation::TraceContextPropagator::new(),
232+
);
246233
}
247234
}
248235

0 commit comments

Comments
 (0)