1 | #![cfg (feature = "registry" )] |
2 | use tracing_futures::{Instrument, WithSubscriber}; |
3 | use tracing_subscriber::prelude::*; |
4 | |
5 | #[tokio::test ] |
6 | async fn future_with_subscriber() { |
7 | tracing_subscriber::registry().init(); |
8 | let span = tracing::info_span!("foo" ); |
9 | let _e = span.enter(); |
10 | let span = tracing::info_span!("bar" ); |
11 | let _e = span.enter(); |
12 | tokio::spawn( |
13 | async { |
14 | async { |
15 | let span = tracing::Span::current(); |
16 | println!("{:?}" , span); |
17 | } |
18 | .instrument(tracing::info_span!("hi" )) |
19 | .await |
20 | } |
21 | .with_subscriber(tracing_subscriber::registry()), |
22 | ) |
23 | .await |
24 | .unwrap(); |
25 | } |
26 | |