diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index e71d85239c..6b163dfba4 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- rust: [stable, 1.40.0]
+ rust: [stable, 1.42.0]
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
@@ -145,7 +145,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- rust: [stable, beta, nightly, 1.40.0]
+ rust: [stable, beta, nightly, 1.42.0]
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000000..1ca1d80290
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,26 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "cargo",
+ "command": "build",
+ "problemMatcher": [
+ "$rustc"
+ ],
+ "group": "build",
+ "label": "rust: cargo build"
+ },
+ {
+ "type": "cargo",
+ "command": "clippy",
+ "args": [
+ "--all"
+ ],
+ "problemMatcher": [
+ "$rustc"
+ ],
+ "group": "build",
+ "label": "rust: cargo clippy"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 1c3057aeee..a3e0b362aa 100644
--- a/README.md
+++ b/README.md
@@ -256,7 +256,7 @@ attachment that `Future::instrument` does.
## Supported Rust Versions
Tracing is built against the latest stable release. The minimum supported
-version is 1.40. The current Tracing version is not guaranteed to build on Rust
+version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.
Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index efd932df71..d3de6c941c 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -10,15 +10,15 @@ default = []
[dev-dependencies]
# tracing crates
-tracing = { path = "../tracing", version = "0.1"}
-tracing-core = { path = "../tracing-core", version = "0.1"}
+tracing = { path = "../tracing", version = "0.2"}
+tracing-core = { path = "../tracing-core", version = "0.2"}
tracing-error = { path = "../tracing-error" }
tracing-flame = { path = "../tracing-flame" }
tracing-tower = { version = "0.1.0", path = "../tracing-tower" }
-tracing-subscriber = { path = "../tracing-subscriber", version = "0.2.12", features = ["json", "chrono"] }
-tracing-futures = { version = "0.2.1", path = "../tracing-futures", features = ["futures-01"] }
-tracing-attributes = { path = "../tracing-attributes", version = "0.1.2"}
-tracing-log = { path = "../tracing-log", version = "0.1.1", features = ["env_logger"] }
+tracing-subscriber = { path = "../tracing-subscriber", version = "0.3", features = ["json", "chrono"] }
+tracing-futures = { version = "0.3", path = "../tracing-futures", features = ["futures-01"] }
+tracing-attributes = { path = "../tracing-attributes", version = "0.2"}
+tracing-log = { path = "../tracing-log", version = "0.2", features = ["env_logger"] }
tracing-serde = { path = "../tracing-serde" }
tracing-opentelemetry = { path = "../tracing-opentelemetry" }
tracing-journald = { path = "../tracing-journald" }
diff --git a/examples/examples/all-levels.rs b/examples/examples/all-levels.rs
index 34f8e944f3..692204add0 100644
--- a/examples/examples/all-levels.rs
+++ b/examples/examples/all-levels.rs
@@ -1,5 +1,11 @@
use tracing::Level;
+#[no_mangle]
+#[inline(never)]
+pub fn event() {
+ tracing::info!("general informational messages relevant to users");
+}
+
fn main() {
tracing_subscriber::fmt()
// all spans/events with a level higher than TRACE (e.g, info, warn, etc.)
@@ -7,6 +13,7 @@ fn main() {
.with_max_level(Level::TRACE)
// sets this to be the default, global subscriber for this application.
.init();
+ event();
tracing::error!("SOMETHING IS SERIOUSLY WRONG!!!");
tracing::warn!("important informational messages; might indicate an error");
diff --git a/examples/examples/hyper-echo.rs b/examples/examples/hyper-echo.rs
index 3404a8d5e9..19c664bfdb 100644
--- a/examples/examples/hyper-echo.rs
+++ b/examples/examples/hyper-echo.rs
@@ -16,78 +16,75 @@ async fn echo(req: Request
) -> Result, hyper::Error> {
uri = ?req.uri(),
headers = ?req.headers()
);
- let _enter = span.enter();
- info!("received request");
- let mut response = Response::new(Body::empty());
+ async move {
+ info!("received request");
+ let mut response = Response::new(Body::empty());
- let (rsp_span, resp) = match (req.method(), req.uri().path()) {
- // Serve some instructions at /
- (&Method::GET, "/") => {
- const BODY: &str = "Try POSTing data to /echo";
- *response.body_mut() = Body::from(BODY);
- (span!(Level::INFO, "response", body = %(&BODY)), response)
- }
+ match (req.method(), req.uri().path()) {
+ // Serve some instructions at /
+ (&Method::GET, "/") => {
+ const BODY: &str = "Try POSTing data to /echo";
+ *response.body_mut() = Body::from(BODY);
+ info!(body = %(&BODY), "response",);
+ Ok(response)
+ }
- // Simply echo the body back to the client.
- (&Method::POST, "/echo") => {
- let span = span!(Level::INFO, "response", response_kind = %"echo");
- *response.body_mut() = req.into_body();
- (span, response)
- }
+ // Simply echo the body back to the client.
+ (&Method::POST, "/echo") => {
+ info!(response_kind = %"echo", "response");
+ *response.body_mut() = req.into_body();
+ Ok(response)
+ }
- // Convert to uppercase before sending back to client.
- (&Method::POST, "/echo/uppercase") => {
- let body = hyper::body::to_bytes(req).await?;
- let upper = body
- .iter()
- .map(|byte| byte.to_ascii_uppercase())
- .collect::>();
- debug!(
- body = ?str::from_utf8(&body[..]),
- uppercased = ?str::from_utf8(&upper[..]),
- "uppercased request body"
- );
+ // Convert to uppercase before sending back to client.
+ (&Method::POST, "/echo/uppercase") => {
+ let body = hyper::body::to_bytes(req).await?;
+ let upper = body
+ .iter()
+ .map(|byte| byte.to_ascii_uppercase())
+ .collect::>();
+ debug!(
+ body = ?str::from_utf8(&body[..]),
+ uppercased = ?str::from_utf8(&upper[..]),
+ "uppercased request body"
+ );
- *response.body_mut() = Body::from(upper);
- (
- span!(Level::INFO, "response", response_kind = %"uppercase"),
- response,
- )
- }
+ info!(response_kind = %"uppercase", "response");
+ *response.body_mut() = Body::from(upper);
+ Ok(response)
+ }
- // Reverse the entire body before sending back to the client.
- (&Method::POST, "/echo/reversed") => {
- let span = span!(Level::TRACE, "response", response_kind = %"reversed");
- let _enter = span.enter();
- let body = hyper::body::to_bytes(req).await?;
- let reversed = body.iter().rev().cloned().collect::>();
- debug!(
- body = ?str::from_utf8(&body[..]),
- "reversed request body"
- );
- *response.body_mut() = Body::from(reversed);
- (
- span!(Level::INFO, "reversed", body = ?(&response.body())),
- response,
- )
- }
+ // Reverse the entire body before sending back to the client.
+ (&Method::POST, "/echo/reversed") => {
+ async move {
+ let body = hyper::body::to_bytes(req).await?;
+ let reversed = body.iter().rev().cloned().collect::>();
+ debug!(
+ body = ?str::from_utf8(&body[..]),
+ "reversed request body"
+ );
+ *response.body_mut() = Body::from(reversed);
+ info!(body = ?(&response.body()), "response");
+ Ok(response)
+ }
+ .instrument(span!(Level::TRACE, "response", response_kind = %"reversed"))
+ .await
+ }
- // The 404 Not Found route...
- _ => {
- *response.status_mut() = StatusCode::NOT_FOUND;
- (
- span!(
- Level::TRACE,
- "response",
+ // The 404 Not Found route...
+ _ => {
+ *response.status_mut() = StatusCode::NOT_FOUND;
+ info!(
body = ?(),
status = ?StatusCode::NOT_FOUND,
- ),
- response,
- )
+ "response",
+ );
+ Ok(response)
+ }
}
- };
- let f = async { resp }.instrument(rsp_span);
- Ok(f.await)
+ }
+ .instrument(span)
+ .await
}
#[tokio::main]
@@ -107,14 +104,13 @@ async fn main() -> Result<(), Box> {
let local_addr: std::net::SocketAddr = ([127, 0, 0, 1], 3000).into();
let server_span = span!(Level::TRACE, "server", %local_addr);
- let _enter = server_span.enter();
let service = make_service_fn(|_| async { Ok::<_, hyper::Error>(service_fn(echo)) });
let server = Server::bind(&local_addr)
.serve(service)
.instrument(server_span.clone());
- info!("listening...");
+ info!(parent: &server_span, "listening...");
server.await?;
Ok(())
diff --git a/tracing-appender/Cargo.toml b/tracing-appender/Cargo.toml
index f0f695713a..2c3b5c2e63 100644
--- a/tracing-appender/Cargo.toml
+++ b/tracing-appender/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tracing-appender"
-version = "0.1.1"
+version = "0.2.0"
authors = [
"Zeki Sherif ",
"Tokio Contributors "
@@ -25,10 +25,10 @@ chrono = "0.4.11"
[dependencies.tracing-subscriber]
path = "../tracing-subscriber"
-version = "0.2.7"
+version = "0.3"
default-features = false
features = ["fmt"]
[dev-dependencies]
-tracing = { path = "../tracing", version = "0.1" }
+tracing = { path = "../tracing", version = "0.2" }
tempdir = "0.3"
diff --git a/tracing-appender/README.md b/tracing-appender/README.md
index 5607549c98..4f1748070b 100644
--- a/tracing-appender/README.md
+++ b/tracing-appender/README.md
@@ -36,7 +36,7 @@ allows events and spans to be recorded in a non-blocking manner through a
dedicated logging thread. It also provides a [`RollingFileAppender`][file_appender]
that can be used with _or_ without the non-blocking writer.
-*Compiler support: [requires `rustc` 1.40+][msrv]*
+*Compiler support: [requires `rustc` 1.42+][msrv]*
[msrv]: #supported-rust-versions
@@ -146,7 +146,7 @@ fn main() {
## Supported Rust Versions
Tracing is built against the latest stable release. The minimum supported
-version is 1.40. The current Tracing version is not guaranteed to build on Rust
+version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.
Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/tracing-appender/src/lib.rs b/tracing-appender/src/lib.rs
index cd3ea6110e..e608577bf5 100644
--- a/tracing-appender/src/lib.rs
+++ b/tracing-appender/src/lib.rs
@@ -7,7 +7,7 @@
//! a dedicated logging thread. It also provides a [`RollingFileAppender`][file_appender] that can
//! be used with _or_ without the non-blocking writer.
//!
-//! *Compiler support: [requires `rustc` 1.40+][msrv]*
+//! *Compiler support: [requires `rustc` 1.42+][msrv]*
//!
//! [msrv]: #supported-rust-versions
//! [file_appender]: ./rolling/struct.RollingFileAppender.html
@@ -111,7 +111,7 @@
//! ## Supported Rust Versions
//!
//! Tracing is built against the latest stable release. The minimum supported
-//! version is 1.40. The current Tracing version is not guaranteed to build on
+//! version is 1.42. The current Tracing version is not guaranteed to build on
//! Rust versions earlier than the minimum supported version.
//!
//! Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/tracing-attributes/Cargo.toml b/tracing-attributes/Cargo.toml
index 2dae754a43..d351783e6d 100644
--- a/tracing-attributes/Cargo.toml
+++ b/tracing-attributes/Cargo.toml
@@ -7,8 +7,8 @@ name = "tracing-attributes"
# - Cargo.toml
# - README.md
# - Update CHANGELOG.md.
-# - Create "v0.1.x" git tag.
-version = "0.1.11"
+# - Create "v0.2.x" git tag.
+version = "0.2.0"
authors = [
"Tokio Contributors ",
"Eliza Weisman ",
@@ -32,11 +32,6 @@ edition = "2018"
[lib]
proc-macro = true
-[features]
-
-# This feature flag is no longer necessary.
-async-await = []
-
[dependencies]
proc-macro2 = "1"
syn = { version = "1", default-features = false, features = ["full", "parsing", "printing", "visit-mut", "clone-impls", "extra-traits", "proc-macro"] }
@@ -44,9 +39,9 @@ quote = "1"
[dev-dependencies]
-tracing = { path = "../tracing", version = "0.1" }
+tracing = { path = "../tracing", version = "0.2" }
tokio-test = { version = "0.2.0" }
-tracing-core = { path = "../tracing-core", version = "0.1"}
+tracing-core = { path = "../tracing-core", version = "0.2"}
async-trait = "0.1"
[badges]
diff --git a/tracing-attributes/README.md b/tracing-attributes/README.md
index a1dc2ee714..64f1527f26 100644
--- a/tracing-attributes/README.md
+++ b/tracing-attributes/README.md
@@ -37,7 +37,7 @@ structured, event-based diagnostic information. This crate provides the
Note that this macro is also re-exported by the main `tracing` crate.
-*Compiler support: [requires `rustc` 1.40+][msrv]*
+*Compiler support: [requires `rustc` 1.42+][msrv]*
[msrv]: #supported-rust-versions
@@ -69,7 +69,7 @@ pub fn my_function(my_arg: usize) {
## Supported Rust Versions
Tracing is built against the latest stable release. The minimum supported
-version is 1.40. The current Tracing version is not guaranteed to build on Rust
+version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.
Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/tracing-attributes/src/lib.rs b/tracing-attributes/src/lib.rs
index fd5f854a64..7cffaf6d56 100644
--- a/tracing-attributes/src/lib.rs
+++ b/tracing-attributes/src/lib.rs
@@ -6,7 +6,7 @@
//!
//! Note that this macro is also re-exported by the main `tracing` crate.
//!
-//! *Compiler support: [requires `rustc` 1.40+][msrv]*
+//! *Compiler support: [requires `rustc` 1.42+][msrv]*
//!
//! [msrv]: #supported-rust-versions
//!
@@ -41,7 +41,7 @@
//! ## Supported Rust Versions
//!
//! Tracing is built against the latest stable release. The minimum supported
-//! version is 1.40. The current Tracing version is not guaranteed to build on
+//! version is 1.42. The current Tracing version is not guaranteed to build on
//! Rust versions earlier than the minimum supported version.
//!
//! Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/tracing-attributes/tests/async_fn.rs b/tracing-attributes/tests/async_fn.rs
index ac95e94d2e..f7e5f3b743 100644
--- a/tracing-attributes/tests/async_fn.rs
+++ b/tracing-attributes/tests/async_fn.rs
@@ -223,7 +223,7 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() {
async fn call_with_self(&self) {}
#[instrument(fields(Self=std::any::type_name::()))]
- async fn call_with_mut_self(self: &mut Self) {}
+ async fn call_with_mut_self(&mut self) {}
}
//let span = span::mock().named("call");
diff --git a/tracing-core/CHANGELOG.md b/tracing-core/CHANGELOG.md
index 40e22a6442..4d04e65229 100644
--- a/tracing-core/CHANGELOG.md
+++ b/tracing-core/CHANGELOG.md
@@ -1,3 +1,20 @@
+# 0.1.17 (September 28, 2020)
+
+### Fixed
+
+- Incorrect inlining of `Event::dispatch` and `Event::child_of`, which could
+ result in `dispatcher::get_default` being inlined at the callsite ([#994])
+
+### Added
+
+- `Copy` implementations for `Level` and `LevelFilter` ([#992])
+
+Thanks to new contributors @jyn514 and @TaKO8Ki for contributing to this
+release!
+
+[#994]: https://github.com/tokio-rs/tracing/pull/994
+[#992]: https://github.com/tokio-rs/tracing/pull/992
+
# 0.1.16 (September 8, 2020)
### Fixed
diff --git a/tracing-core/Cargo.toml b/tracing-core/Cargo.toml
index 3f40649c0a..2e915afc66 100644
--- a/tracing-core/Cargo.toml
+++ b/tracing-core/Cargo.toml
@@ -7,8 +7,8 @@ name = "tracing-core"
# - Cargo.toml
# - README.md
# - Update CHANGELOG.md.
-# - Create "v0.1.x" git tag.
-version = "0.1.16"
+# - Create "v0.2.x" git tag.
+version = "0.2.0"
authors = ["Tokio Contributors "]
license = "MIT"
readme = "README.md"
diff --git a/tracing-core/README.md b/tracing-core/README.md
index 6b7714563c..715af65370 100644
--- a/tracing-core/README.md
+++ b/tracing-core/README.md
@@ -16,9 +16,9 @@ Core primitives for application-level tracing.
[Documentation][docs-url] | [Chat][discord-url]
[crates-badge]: https://img.shields.io/crates/v/tracing-core.svg
-[crates-url]: https://crates.io/crates/tracing-core/0.1.16
+[crates-url]: https://crates.io/crates/tracing-core/0.1.17
[docs-badge]: https://docs.rs/tracing-core/badge.svg
-[docs-url]: https://docs.rs/tracing-core/0.1.16
+[docs-url]: https://docs.rs/tracing-core/0.1.17
[docs-master-badge]: https://img.shields.io/badge/docs-master-blue
[docs-master-url]: https://tracing-rs.netlify.com/tracing_core
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
@@ -53,7 +53,7 @@ The crate provides:
In addition, it defines the global callsite registry and per-thread current
dispatcher which other components of the tracing system rely on.
-*Compiler support: [requires `rustc` 1.40+][msrv]*
+*Compiler support: [requires `rustc` 1.42+][msrv]*
[msrv]: #supported-rust-versions
@@ -79,27 +79,27 @@ The following crate feature flags are available:
```toml
[dependencies]
- tracing-core = { version = "0.1.16", default-features = false }
+ tracing-core = { version = "0.1.17", default-features = false }
```
**Note**:`tracing-core`'s `no_std` support requires `liballoc`.
[`tracing`]: ../tracing
-[`span::Id`]: https://docs.rs/tracing-core/0.1.16/tracing_core/span/struct.Id.html
-[`Event`]: https://docs.rs/tracing-core/0.1.16/tracing_core/event/struct.Event.html
-[`Subscriber`]: https://docs.rs/tracing-core/0.1.16/tracing_core/subscriber/trait.Subscriber.html
-[`Metadata`]: https://docs.rs/tracing-core/0.1.16/tracing_core/metadata/struct.Metadata.html
-[`Callsite`]: https://docs.rs/tracing-core/0.1.16/tracing_core/callsite/trait.Callsite.html
-[`Field`]: https://docs.rs/tracing-core/0.1.16/tracing_core/field/struct.Field.html
-[`FieldSet`]: https://docs.rs/tracing-core/0.1.16/tracing_core/field/struct.FieldSet.html
-[`Value`]: https://docs.rs/tracing-core/0.1.16/tracing_core/field/trait.Value.html
-[`ValueSet`]: https://docs.rs/tracing-core/0.1.16/tracing_core/field/struct.ValueSet.html
-[`Dispatch`]: https://docs.rs/tracing-core/0.1.16/tracing_core/dispatcher/struct.Dispatch.html
+[`span::Id`]: https://docs.rs/tracing-core/0.1.17/tracing_core/span/struct.Id.html
+[`Event`]: https://docs.rs/tracing-core/0.1.17/tracing_core/event/struct.Event.html
+[`Subscriber`]: https://docs.rs/tracing-core/0.1.17/tracing_core/subscriber/trait.Subscriber.html
+[`Metadata`]: https://docs.rs/tracing-core/0.1.17/tracing_core/metadata/struct.Metadata.html
+[`Callsite`]: https://docs.rs/tracing-core/0.1.17/tracing_core/callsite/trait.Callsite.html
+[`Field`]: https://docs.rs/tracing-core/0.1.17/tracing_core/field/struct.Field.html
+[`FieldSet`]: https://docs.rs/tracing-core/0.1.17/tracing_core/field/struct.FieldSet.html
+[`Value`]: https://docs.rs/tracing-core/0.1.17/tracing_core/field/trait.Value.html
+[`ValueSet`]: https://docs.rs/tracing-core/0.1.17/tracing_core/field/struct.ValueSet.html
+[`Dispatch`]: https://docs.rs/tracing-core/0.1.17/tracing_core/dispatcher/struct.Dispatch.html
## Supported Rust Versions
Tracing is built against the latest stable release. The minimum supported
-version is 1.40. The current Tracing version is not guaranteed to build on Rust
+version is 1.42. The current Tracing version is not guaranteed to build on Rust
versions earlier than the minimum supported version.
Tracing follows the same compiler support policies as the rest of the Tokio
diff --git a/tracing-core/src/callsite.rs b/tracing-core/src/callsite.rs
index 5e48473e15..262642a757 100644
--- a/tracing-core/src/callsite.rs
+++ b/tracing-core/src/callsite.rs
@@ -1,73 +1,32 @@
//! Callsites represent the source locations from which spans or events
//! originate.
-use crate::stdlib::{
- fmt,
- hash::{Hash, Hasher},
- sync::Mutex,
- vec::Vec,
-};
use crate::{
dispatcher::{self, Dispatch},
metadata::{LevelFilter, Metadata},
subscriber::Interest,
+ sync::{Mutex, MutexGuard},
+};
+use alloc::vec::Vec;
+use core::{
+ fmt,
+ hash::{Hash, Hasher},
+ ptr,
+ sync::atomic::{AtomicPtr, Ordering},
};
lazy_static! {
- static ref REGISTRY: Mutex = Mutex::new(Registry {
- callsites: Vec::new(),
- dispatchers: Vec::new(),
- });
+ static ref REGISTRY: Registry = Registry {
+ callsites: LinkedList::new(),
+ dispatchers: Mutex::new(Vec::new()),
+ };
}
-struct Registry {
- callsites: Vec<&'static dyn Callsite>,
- dispatchers: Vec,
-}
-
-impl Registry {
- fn rebuild_callsite_interest(&self, callsite: &'static dyn Callsite) {
- let meta = callsite.metadata();
-
- // Iterate over the subscribers in the registry, and — if they are
- // active — register the callsite with them.
- let mut interests = self
- .dispatchers
- .iter()
- .filter_map(|registrar| registrar.try_register(meta));
-
- // Use the first subscriber's `Interest` as the base value.
- let interest = if let Some(interest) = interests.next() {
- // Combine all remaining `Interest`s.
- interests.fold(interest, Interest::and)
- } else {
- // If nobody was interested in this thing, just return `never`.
- Interest::never()
- };
+type Dispatchers = Vec;
+type Callsites = LinkedList;
- callsite.set_interest(interest)
- }
-
- fn rebuild_interest(&mut self) {
- let mut max_level = LevelFilter::OFF;
- self.dispatchers.retain(|registrar| {
- if let Some(dispatch) = registrar.upgrade() {
- // If the subscriber did not provide a max level hint, assume
- // that it may enable every level.
- let level_hint = dispatch.max_level_hint().unwrap_or(LevelFilter::TRACE);
- if level_hint > max_level {
- max_level = level_hint;
- }
- true
- } else {
- false
- }
- });
-
- self.callsites.iter().for_each(|&callsite| {
- self.rebuild_callsite_interest(callsite);
- });
- LevelFilter::set_max(max_level);
- }
+struct Registry {
+ callsites: Callsites,
+ dispatchers: Mutex,
}
/// Trait implemented by callsites.
@@ -77,12 +36,12 @@ impl Registry {
pub trait Callsite: Sync {
/// Sets the [`Interest`] for this callsite.
///
- /// [`Interest`]: ../subscriber/struct.Interest.html
+ /// [`Interest`]: super::subscriber::Interest
fn set_interest(&self, interest: Interest);
/// Returns the [metadata] associated with the callsite.
///
- /// [metadata]: ../metadata/struct.Metadata.html
+ /// [metadata]: super::metadata::Metadata
fn metadata(&self) -> &Metadata<'_>;
}
@@ -90,7 +49,7 @@ pub trait Callsite: Sync {
///
/// Two `Identifier`s are equal if they both refer to the same callsite.
///
-/// [`Callsite`]: ../callsite/trait.Callsite.html
+/// [`Callsite`]: super::callsite::Callsite
#[derive(Clone)]
pub struct Identifier(
/// **Warning**: The fields on this type are currently `pub` because it must
@@ -105,6 +64,18 @@ pub struct Identifier(
pub &'static dyn Callsite,
);
+/// A registration with the callsite registry.
+///
+/// Every [`Callsite`] implementation must provide a `&'static Registration`
+/// when calling [`register`] to add itself to the global callsite registry.
+///
+/// [`Callsite`]: crate::callsite::Callsite
+/// [`register`]: crate::callsite::register
+pub struct Registration {
+ callsite: T,
+ next: AtomicPtr>,
+}
+
/// Clear and reregister interest on every [`Callsite`]
///
/// This function is intended for runtime reconfiguration of filters on traces
@@ -119,30 +90,82 @@ pub struct Identifier(
/// implementation at runtime, then it **must** call this function after that
/// value changes, in order for the change to be reflected.
///
-/// [`max_level_hint`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
-/// [`Callsite`]: ../callsite/trait.Callsite.html
-/// [`enabled`]: ../subscriber/trait.Subscriber.html#tymethod.enabled
-/// [`Interest::sometimes()`]: ../subscriber/struct.Interest.html#method.sometimes
-/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
+/// [`max_level_hint`]: super::subscriber::Subscriber::max_level_hint
+/// [`Callsite`]: super::callsite::Callsite
+/// [`enabled`]: super::subscriber::Subscriber::enabled
+/// [`Interest::sometimes()`]: super::subscriber::Interest::sometimes
+/// [`Subscriber`]: super::subscriber::Subscriber
pub fn rebuild_interest_cache() {
- let mut registry = REGISTRY.lock().unwrap();
- registry.rebuild_interest();
+ let mut dispatchers = REGISTRY.dispatchers.lock().unwrap();
+ let callsites = ®ISTRY.callsites;
+ rebuild_interest(callsites, &mut dispatchers);
}
/// Register a new `Callsite` with the global registry.
///
/// This should be called once per callsite after the callsite has been
/// constructed.
-pub fn register(callsite: &'static dyn Callsite) {
- let mut registry = REGISTRY.lock().unwrap();
- registry.rebuild_callsite_interest(callsite);
- registry.callsites.push(callsite);
+pub fn register(registration: &'static Registration) {
+ let mut dispatchers = REGISTRY.dispatchers.lock().unwrap();
+ rebuild_callsite_interest(&mut dispatchers, registration.callsite);
+ REGISTRY.callsites.push(registration);
}
pub(crate) fn register_dispatch(dispatch: &Dispatch) {
- let mut registry = REGISTRY.lock().unwrap();
- registry.dispatchers.push(dispatch.registrar());
- registry.rebuild_interest();
+ let mut dispatchers = REGISTRY.dispatchers.lock().unwrap();
+ let callsites = ®ISTRY.callsites;
+
+ dispatchers.push(dispatch.registrar());
+
+ rebuild_interest(callsites, &mut dispatchers);
+}
+
+fn rebuild_callsite_interest(
+ dispatchers: &mut MutexGuard<'_, Vec>,
+ callsite: &'static dyn Callsite,
+) {
+ let meta = callsite.metadata();
+
+ // Iterate over the subscribers in the registry, and — if they are
+ // active — register the callsite with them.
+ let mut interests = dispatchers
+ .iter()
+ .filter_map(|registrar| registrar.try_register(meta));
+
+ // Use the first subscriber's `Interest` as the base value.
+ let interest = if let Some(interest) = interests.next() {
+ // Combine all remaining `Interest`s.
+ interests.fold(interest, Interest::and)
+ } else {
+ // If nobody was interested in this thing, just return `never`.
+ Interest::never()
+ };
+
+ callsite.set_interest(interest)
+}
+
+fn rebuild_interest(
+ callsites: &Callsites,
+ dispatchers: &mut MutexGuard<'_, Vec>,
+) {
+ let mut max_level = LevelFilter::OFF;
+ dispatchers.retain(|registrar| {
+ if let Some(dispatch) = registrar.upgrade() {
+ // If the subscriber did not provide a max level hint, assume
+ // that it may enable every level.
+ let level_hint = dispatch.max_level_hint().unwrap_or(LevelFilter::TRACE);
+ if level_hint > max_level {
+ max_level = level_hint;
+ }
+ true
+ } else {
+ false
+ }
+ });
+
+ callsites.for_each(|reg| rebuild_callsite_interest(dispatchers, reg.callsite));
+
+ LevelFilter::set_max(max_level);
}
// ===== impl Identifier =====
@@ -169,3 +192,206 @@ impl Hash for Identifier {
(self.0 as *const dyn Callsite).hash(state)
}
}
+
+// ===== impl Registration =====
+
+impl Registration {
+ /// Construct a new `Registration` from some `&'static dyn Callsite`
+ pub const fn new(callsite: T) -> Self {
+ Self {
+ callsite,
+ next: AtomicPtr::new(ptr::null_mut()),
+ }
+ }
+}
+
+impl fmt::Debug for Registration {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("Registration")
+ .field("callsite", &format_args!("{:p}", self.callsite))
+ .field(
+ "next",
+ &format_args!("{:p}", self.next.load(Ordering::Acquire)),
+ )
+ .finish()
+ }
+}
+
+// ===== impl LinkedList =====
+
+/// An intrusive atomic push-only linked list.
+struct LinkedList {
+ head: AtomicPtr,
+}
+
+impl LinkedList {
+ fn new() -> Self {
+ LinkedList {
+ head: AtomicPtr::new(ptr::null_mut()),
+ }
+ }
+
+ fn for_each(&self, mut f: impl FnMut(&'static Registration)) {
+ let mut head = self.head.load(Ordering::Acquire);
+
+ while let Some(reg) = unsafe { head.as_ref() } {
+ f(reg);
+
+ head = reg.next.load(Ordering::Acquire);
+ }
+ }
+
+ fn push(&self, registration: &'static Registration) {
+ let mut head = self.head.load(Ordering::Acquire);
+
+ loop {
+ registration.next.store(head, Ordering::Release);
+
+ assert_ne!(
+ registration as *const _, head,
+ "Attempted to register a `Callsite` that already exists! \
+ This will cause an infinite loop when attempting to read from the \
+ callsite cache. This is likely a bug! You should only need to call \
+ `tracing-core::callsite::register` once per `Callsite`."
+ );
+
+ match self.head.compare_exchange(
+ head,
+ registration as *const _ as *mut _,
+ Ordering::AcqRel,
+ Ordering::Acquire,
+ ) {
+ Ok(_) => {
+ break;
+ }
+ Err(current) => head = current,
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ struct TestCallsite;
+ static CS1: TestCallsite = TestCallsite;
+ static CS2: TestCallsite = TestCallsite;
+
+ impl Callsite for TestCallsite {
+ fn set_interest(&self, _interest: Interest) {}
+ fn metadata(&self) -> &Metadata<'_> {
+ unimplemented!("not needed for this test")
+ }
+ }
+
+ #[test]
+ fn linked_list_push() {
+ static REG1: Registration = Registration::new(&CS1);
+ static REG2: Registration = Registration::new(&CS2);
+
+ let linked_list = LinkedList::new();
+
+ linked_list.push(®1);
+ linked_list.push(®2);
+
+ let mut i = 0;
+
+ linked_list.for_each(|reg| {
+ if i == 0 {
+ assert!(
+ ptr::eq(reg, ®2),
+ "Registration pointers need to match REG2"
+ );
+ } else {
+ assert!(
+ ptr::eq(reg, ®1),
+ "Registration pointers need to match REG1"
+ );
+ }
+
+ i += 1;
+ });
+ }
+
+ #[test]
+ fn linked_list_push_several() {
+ static REG1: Registration = Registration::new(&CS1);
+ static REG2: Registration = Registration::new(&CS2);
+ static REG3: Registration = Registration::new(&CS1);
+ static REG4: Registration = Registration::new(&CS2);
+
+ let linked_list = LinkedList::new();
+
+ fn expect<'a>(
+ callsites: &'a mut impl Iterator,
+ ) -> impl FnMut(&'static Registration) + 'a {
+ move |reg: &'static Registration| {
+ let ptr = callsites
+ .next()
+ .expect("list contained more than the expected number of registrations!");
+
+ assert!(
+ ptr::eq(reg, ptr),
+ "Registration pointers need to match ({:?} != {:?})",
+ reg,
+ ptr
+ );
+ }
+ }
+
+ linked_list.push(®1);
+ linked_list.push(®2);
+ let regs = [®2, ®1];
+ let mut callsites = regs.iter().copied();
+ linked_list.for_each(expect(&mut callsites));
+ assert!(
+ callsites.next().is_none(),
+ "some registrations were expected but not present: {:?}",
+ callsites
+ );
+
+ linked_list.push(®3);
+ let regs = [®3, ®2, ®1];
+ let mut callsites = regs.iter().copied();
+ linked_list.for_each(expect(&mut callsites));
+ assert!(
+ callsites.next().is_none(),
+ "some registrations were expected but not present: {:?}",
+ callsites
+ );
+
+ linked_list.push(®4);
+ let regs = [®4, ®3, ®2, ®1];
+ let mut callsites = regs.iter().copied();
+ linked_list.for_each(expect(&mut callsites));
+ assert!(
+ callsites.next().is_none(),
+ "some registrations were expected but not present: {:?}",
+ callsites
+ );
+ }
+
+ #[test]
+ #[should_panic]
+ fn linked_list_repeated() {
+ static REG1: Registration = Registration::new(&CS1);
+
+ let linked_list = LinkedList::new();
+
+ linked_list.push(®1);
+ // Pass in same reg and we should panic...
+ linked_list.push(®1);
+
+ linked_list.for_each(|_| {});
+ }
+
+ #[test]
+ fn linked_list_empty() {
+ let linked_list = LinkedList::new();
+
+ linked_list.for_each(|_| {
+ panic!("List should be empty");
+ });
+ }
+}
diff --git a/tracing-core/src/dispatcher.rs b/tracing-core/src/dispatcher.rs
index 658463584e..69bfdefd61 100644
--- a/tracing-core/src/dispatcher.rs
+++ b/tracing-core/src/dispatcher.rs
@@ -113,11 +113,10 @@
//!
//!
//!
-//! Note:the thread-local scoped dispatcher
-//! (with_default) requires the
-//! Rust standard library. no_std users should use
-//! set_global_default
-//! instead.
+//!
+//! **Note**: the thread-local scoped dispatcher ([`with_default`]) requires the
+//! Rust standard library. `no_std` users should use [`set_global_default`] instead.
+//!
//!
//!
//! ## Accessing the Default Subscriber
@@ -126,36 +125,26 @@
//! [`get_default`] function, which executes a closure with a reference to the
//! currently default `Dispatch`. This is used primarily by `tracing`
//! instrumentation.
-//!
-//! [`Subscriber`]: struct.Subscriber.html
-//! [`with_default`]: fn.with_default.html
-//! [`set_global_default`]: fn.set_global_default.html
-//! [`get_default`]: fn.get_default.html
-//! [`Dispatch`]: struct.Dispatch.html
use crate::{
callsite, span,
subscriber::{self, Subscriber},
Event, LevelFilter, Metadata,
};
-use crate::stdlib::{
+use alloc::sync::{Arc, Weak};
+use core::{
any::Any,
fmt,
- sync::{
- atomic::{AtomicBool, AtomicUsize, Ordering},
- Arc, Weak,
- },
+ sync::atomic::{AtomicBool, AtomicUsize, Ordering},
};
#[cfg(feature = "std")]
-use crate::stdlib::{
+use std::{
cell::{Cell, RefCell, RefMut},
error,
};
/// `Dispatch` trace data to a [`Subscriber`].
-///
-/// [`Subscriber`]: trait.Subscriber.html
#[derive(Clone)]
pub struct Dispatch {
subscriber: Arc,
@@ -217,14 +206,15 @@ pub struct DefaultGuard(Option);
///
///
/// Note: This function required the Rust standard library.
-/// no_std users should use
-/// set_global_default instead.
+///
+///
+/// `no_std` users should use [`set_global_default`] instead.
+///
///
-/// Note: This function required the Rust standard library.
-/// no_std users should use
-/// set_global_default instead.
-///
///
-/// [`set_global_default`]: ../fn.set_global_default.html
+/// **Note**: This function required the Rust standard library.
+/// `no_std` users should use [`set_global_default`] instead.
+///
+///
#[cfg(feature = "std")]
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
#[must_use = "Dropping the guard unregisters the dispatcher."]
@@ -276,9 +265,9 @@ pub fn set_default(dispatcher: &Dispatch) -> DefaultGuard {
/// executables that depend on the library try to set the default later.
///
///
-/// [span]: ../span/index.html
-/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
-/// [`Event`]: ../event/struct.Event.html
+/// [span]: super::span
+/// [`Subscriber`]: super::subscriber::Subscriber
+/// [`Event`]: super::event::Event
pub fn set_global_default(dispatcher: Dispatch) -> Result<(), SetGlobalDefaultError> {
if GLOBAL_INIT.compare_and_swap(UNINITIALIZED, INITIALIZING, Ordering::SeqCst) == UNINITIALIZED
{
@@ -325,7 +314,7 @@ impl error::Error for SetGlobalDefaultError {}
/// called while inside of another `get_default`, that closure will be provided
/// with `Dispatch::none` rather than the previously set dispatcher.
///
-/// [dispatcher]: ../dispatcher/struct.Dispatch.html
+/// [dispatcher]: super::dispatcher::Dispatch
#[cfg(feature = "std")]
pub fn get_default(mut f: F) -> T
where
@@ -348,7 +337,7 @@ where
/// called while inside of another `get_default`, that closure will be provided
/// with `Dispatch::none` rather than the previously set dispatcher.
///
-/// [dispatcher]: ../dispatcher/struct.Dispatch.html
+/// [dispatcher]: super::dispatcher::Dispatch
#[cfg(feature = "std")]
#[doc(hidden)]
#[inline(never)]
@@ -363,7 +352,7 @@ pub fn get_current(f: impl FnOnce(&Dispatch) -> T) -> Option {
/// Executes a closure with a reference to the current [dispatcher].
///
-/// [dispatcher]: ../dispatcher/struct.Dispatch.html
+/// [dispatcher]: super::dispatcher::Dispatch
#[cfg(not(feature = "std"))]
#[doc(hidden)]
pub fn get_current(f: impl FnOnce(&Dispatch) -> T) -> Option {
@@ -373,7 +362,7 @@ pub fn get_current(f: impl FnOnce(&Dispatch) -> T) -> Option {
/// Executes a closure with a reference to the current [dispatcher].
///
-/// [dispatcher]: ../dispatcher/struct.Dispatch.html
+/// [dispatcher]: super::dispatcher::Dispatch
#[cfg(not(feature = "std"))]
pub fn get_default(mut f: F) -> T
where
@@ -412,7 +401,7 @@ impl Dispatch {
/// Returns a `Dispatch` that forwards to the given [`Subscriber`].
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
+ /// [`Subscriber`]: super::subscriber::Subscriber
pub fn new(subscriber: S) -> Self
where
S: Subscriber + Send + Sync + 'static,
@@ -434,8 +423,8 @@ impl Dispatch {
/// This calls the [`register_callsite`] function on the [`Subscriber`]
/// that this `Dispatch` forwards to.
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`register_callsite`]: ../subscriber/trait.Subscriber.html#method.register_callsite
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`register_callsite`]: super::subscriber::Subscriber::register_callsite
#[inline]
pub fn register_callsite(&self, metadata: &'static Metadata<'static>) -> subscriber::Interest {
self.subscriber.register_callsite(metadata)
@@ -448,9 +437,9 @@ impl Dispatch {
/// This calls the [`max_level_hint`] function on the [`Subscriber`]
/// that this `Dispatch` forwards to.
///
- /// [level]: ../struct.Level.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`register_callsite`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
+ /// [level]: super::Level
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`register_callsite`]: super::subscriber::Subscriber::max_level_hint
// TODO(eliza): consider making this a public API?
#[inline]
pub(crate) fn max_level_hint(&self) -> Option {
@@ -463,9 +452,9 @@ impl Dispatch {
/// This calls the [`new_span`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [ID]: ../span/struct.Id.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
+ /// [ID]: super::span::Id
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`new_span`]: super::subscriber::Subscriber::new_span
#[inline]
pub fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
self.subscriber.new_span(span)
@@ -476,8 +465,8 @@ impl Dispatch {
/// This calls the [`record`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`record`]: ../subscriber/trait.Subscriber.html#method.record
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`record`]: super::subscriber::Subscriber::record
#[inline]
pub fn record(&self, span: &span::Id, values: &span::Record<'_>) {
self.subscriber.record(span, values)
@@ -489,8 +478,8 @@ impl Dispatch {
/// This calls the [`record_follows_from`] function on the [`Subscriber`]
/// that this `Dispatch` forwards to.
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`record_follows_from`]: ../subscriber/trait.Subscriber.html#method.record_follows_from
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`record_follows_from`]: super::subscriber::Subscriber::record_follows_from
#[inline]
pub fn record_follows_from(&self, span: &span::Id, follows: &span::Id) {
self.subscriber.record_follows_from(span, follows)
@@ -502,9 +491,9 @@ impl Dispatch {
/// This calls the [`enabled`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [metadata]: ../metadata/struct.Metadata.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`enabled`]: ../subscriber/trait.Subscriber.html#method.enabled
+ /// [metadata]: super::metadata::Metadata
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`enabled`]: super::subscriber::Subscriber::enabled
#[inline]
pub fn enabled(&self, metadata: &Metadata<'_>) -> bool {
self.subscriber.enabled(metadata)
@@ -515,9 +504,9 @@ impl Dispatch {
/// This calls the [`event`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [`Event`]: ../event/struct.Event.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`event`]: ../subscriber/trait.Subscriber.html#method.event
+ /// [`Event`]: super::event::Event
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`event`]: super::subscriber::Subscriber::event
#[inline]
pub fn event(&self, event: &Event<'_>) {
self.subscriber.event(event)
@@ -528,8 +517,8 @@ impl Dispatch {
/// This calls the [`enter`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`enter`]: ../subscriber/trait.Subscriber.html#method.enter
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`enter`]: super::subscriber::Subscriber::enter
#[inline]
pub fn enter(&self, span: &span::Id) {
self.subscriber.enter(span);
@@ -540,8 +529,8 @@ impl Dispatch {
/// This calls the [`exit`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`exit`]: ../subscriber/trait.Subscriber.html#method.exit
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`exit`]: super::subscriber::Subscriber::exit
#[inline]
pub fn exit(&self, span: &span::Id) {
self.subscriber.exit(span);
@@ -557,10 +546,10 @@ impl Dispatch {
/// This calls the [`clone_span`] function on the `Subscriber` that this
/// `Dispatch` forwards to.
///
- /// [span ID]: ../span/struct.Id.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`clone_span`]: ../subscriber/trait.Subscriber.html#method.clone_span
- /// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
+ /// [span ID]: super::span::Id
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`clone_span`]: super::subscriber::Subscriber::clone_span
+ /// [`new_span`]: super::subscriber::Subscriber::new_span
#[inline]
pub fn clone_span(&self, id: &span::Id) -> span::Id {
self.subscriber.clone_span(&id)
@@ -580,16 +569,17 @@ impl Dispatch {
///
⚠ ️Warning
///
///
- /// Deprecated: The try_close
- /// method is functionally identical, but returns true if the span is now closed.
+ ///
+ /// **Deprecated**: The [`try_close`] method is functionally identical, but returns `true` if the span is now closed.
/// It should be used instead of this method.
+ ///
///
///
- /// [span ID]: ../span/struct.Id.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`drop_span`]: ../subscriber/trait.Subscriber.html#method.drop_span
- /// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
- /// [`try_close`]: #method.try_close
+ /// [span ID]: super::span::Id
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`drop_span`]: super::subscriber::Subscriber::drop_span
+ /// [`new_span`]: super::subscriber::Subscriber::new_span
+ /// [`try_close`]: Self::try_close
#[inline]
#[deprecated(since = "0.1.2", note = "use `Dispatch::try_close` instead")]
pub fn drop_span(&self, id: span::Id) {
@@ -608,10 +598,10 @@ impl Dispatch {
/// This calls the [`try_close`] function on the [`Subscriber`] that this
/// `Dispatch` forwards to.
///
- /// [span ID]: ../span/struct.Id.html
- /// [`Subscriber`]: ../subscriber/trait.Subscriber.html
- /// [`try_close`]: ../subscriber/trait.Subscriber.html#method.try_close
- /// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
+ /// [span ID]: super::span::Id
+ /// [`Subscriber`]: super::subscriber::Subscriber
+ /// [`try_close`]: super::subscriber::Subscriber::try_close
+ /// [`new_span`]: super::subscriber::Subscriber::new_span
#[inline]
pub fn try_close(&self, id: span::Id) -> bool {
self.subscriber.try_close(id)
@@ -622,7 +612,7 @@ impl Dispatch {
/// This calls the [`current`] function on the `Subscriber` that this
/// `Dispatch` forwards to.
///
- /// [`current`]: ../subscriber/trait.Subscriber.html#method.current
+ /// [`current`]: super::subscriber::Subscriber::current_span
#[inline]
pub fn current_span(&self) -> span::Current {
self.subscriber.current_span()
@@ -783,9 +773,8 @@ impl Drop for DefaultGuard {
#[cfg(test)]
mod test {
+
use super::*;
- #[cfg(feature = "std")]
- use crate::stdlib::sync::atomic::{AtomicUsize, Ordering};
use crate::{
callsite::Callsite,
metadata::{Kind, Level, Metadata},
diff --git a/tracing-core/src/event.rs b/tracing-core/src/event.rs
index 1c4b7a7936..b823fa8722 100644
--- a/tracing-core/src/event.rs
+++ b/tracing-core/src/event.rs
@@ -29,7 +29,6 @@ pub struct Event<'a> {
impl<'a> Event<'a> {
/// Constructs a new `Event` with the specified metadata and set of values,
/// and observes it with the current subscriber.
- #[inline]
pub fn dispatch(metadata: &'static Metadata<'static>, fields: &'a field::ValueSet<'_>) {
let event = Event::new(metadata, fields);
crate::dispatcher::get_default(|current| {
@@ -69,7 +68,6 @@ impl<'a> Event<'a> {
/// Constructs a new `Event` with the specified metadata and set of values,
/// and observes it with the current subscriber and an explicit parent.
- #[inline]
pub fn child_of(
parent: impl Into