diff --git a/tracing-subscriber/Cargo.toml b/tracing-subscriber/Cargo.toml index 723f0337fa..fd9a2aee13 100644 --- a/tracing-subscriber/Cargo.toml +++ b/tracing-subscriber/Cargo.toml @@ -4,7 +4,7 @@ version = "0.2.10" authors = [ "Eliza Weisman ", "David Barsky ", - "Tokio Contributors " + "Tokio Contributors ", ] edition = "2018" license = "MIT" @@ -57,11 +57,13 @@ sharded-slab = { version = "^0.0.9", optional = true } thread_local = "1.0.1" [dev-dependencies] -tracing = { path = "../tracing", version = "0.1"} +tracing = { path = "../tracing", version = "0.1" } log = "0.4" tracing-log = { path = "../tracing-log", version = "0.1" } criterion = { version = "0.3", default_features = false } regex = "1" +tracing-futures = { path = "../tracing-futures", version = "0.2", default-features = false, features = ["std-future", "std"] } +tokio = { version = "0.2", features = ["rt-core", "macros"] } [badges] maintenance = { status = "experimental" } diff --git a/tracing-subscriber/tests/registry_with_subscriber.rs b/tracing-subscriber/tests/registry_with_subscriber.rs new file mode 100644 index 0000000000..0f2dce2de0 --- /dev/null +++ b/tracing-subscriber/tests/registry_with_subscriber.rs @@ -0,0 +1,25 @@ + +use tracing_futures::{Instrument, WithSubscriber}; +use tracing_subscriber::prelude::*; + +#[tokio::test] +async fn future_with_subscriber() { + let _default = tracing_subscriber::registry().init(); + let span = tracing::info_span!("foo"); + let _e = span.enter(); + let span = tracing::info_span!("bar"); + let _e = span.enter(); + tokio::spawn( + async { + async { + let span = tracing::Span::current(); + println!("{:?}", span); + } + .instrument(tracing::info_span!("hi")) + .await + } + .with_subscriber(tracing_subscriber::registry()), + ) + .await + .unwrap(); +} \ No newline at end of file