Skip to content

Commit

Permalink
adds a test to ensure multiple registries are possible when using wit…
Browse files Browse the repository at this point in the history
…h_subscriber
  • Loading branch information
jeromegn committed Aug 8, 2020
1 parent cc629ed commit a7ecc2a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tracing-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.10"
authors = [
"Eliza Weisman <[email protected]>",
"David Barsky <[email protected]>",
"Tokio Contributors <[email protected]>"
"Tokio Contributors <[email protected]>",
]
edition = "2018"
license = "MIT"
Expand Down Expand Up @@ -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" }
Expand Down
25 changes: 25 additions & 0 deletions tracing-subscriber/tests/registry_with_subscriber.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit a7ecc2a

Please sign in to comment.