Skip to content

Commit

Permalink
tracing: switch to unstable for 1.0. (#3266)
Browse files Browse the repository at this point in the history
Enabling `tracing` integration now requires compiling with `--cfg
tokio_unstable`. Once `tracing-core` guarantees the same level of
stability as Tokio 1.0, unstable can be removed.

Closes #3258
  • Loading branch information
carllerche authored Dec 15, 2020
1 parent 3f29212 commit 79d25b0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ mio = { version = "0.7.6", optional = true }
num_cpus = { version = "1.8.0", optional = true }
parking_lot = { version = "0.11.0", optional = true }
slab = { version = "0.4.1", optional = true }

# Currently unstable. The API exposed by these features may be broken at any time.
# Requires `--cfg tokio_unstable` to enable.
[target.'cfg(tokio_unstable)'.dependencies]
tracing = { version = "0.1.21", default-features = false, features = ["std"], optional = true } # Not in full

[target.'cfg(unix)'.dependencies]
Expand Down
3 changes: 1 addition & 2 deletions tokio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ several other libraries, including:

* [`tower`]: A library of modular and reusable components for building robust networking clients and servers.

* [`tracing`] (formerly `tokio-trace`): A framework for application-level
tracing and async-aware diagnostics.
* [`tracing`]: A framework for application-level tracing and async-aware diagnostics.

* [`rdbc`]: A Rust database connectivity library for MySQL, Postgres and SQLite.

Expand Down
10 changes: 9 additions & 1 deletion tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@
//! - `signal`: Enables all `tokio::signal` types.
//! - `fs`: Enables `tokio::fs` types.
//! - `test-util`: Enables testing based infrastructure for the Tokio runtime.
//! - `tracing`: Enables tracing events
//!
//! _Note: `AsyncRead` and `AsyncWrite` traits do not require any features and are
//! always available._
Expand All @@ -333,6 +332,15 @@
//! synchronization primitives internally. MSRV may increase according to the
//! _parking_lot_ release in use.
//!
//! ### Unstable features
//!
//! These feature flags enable **unstable** features. The public API may break in 1.x
//! releases. To enable these features, the `--cfg tokio_unstable` must be passed to
//! `rustc` when compiling. This is easiest done using the `RUSTFLAGS` env variable:
//! `RUSTFLAGS="--cfg tokio_unstable"`.
//!
//! - `tracing`: Enables tracing events.
//!
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section

// Includes re-exports used by macros.
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/macros/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ macro_rules! cfg_not_time {
macro_rules! cfg_trace {
($($item:item)*) => {
$(
#[cfg(feature = "tracing")]
#[cfg(all(tokio_unstable, feature = "tracing"))]
#[cfg_attr(docsrs, doc(cfg(feature = "tracing")))]
$item
)*
Expand All @@ -344,7 +344,7 @@ macro_rules! cfg_trace {
macro_rules! cfg_not_trace {
($($item:item)*) => {
$(
#[cfg(not(feature = "tracing"))]
#[cfg(any(not(tokio_unstable), not(feature = "tracing")))]
$item
)*
}
Expand Down
4 changes: 2 additions & 2 deletions tokio/src/runtime/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Handle {
F: Future + Send + 'static,
F::Output: Send + 'static,
{
#[cfg(feature = "tracing")]
#[cfg(all(tokio_unstable, feature = "tracing"))]
let future = crate::util::trace::task(future, "task");
self.spawner.spawn(future)
}
Expand Down Expand Up @@ -172,7 +172,7 @@ impl Handle {
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
#[cfg(feature = "tracing")]
#[cfg(all(tokio_unstable, feature = "tracing"))]
let func = {
#[cfg(tokio_track_caller)]
let location = std::panic::Location::caller();
Expand Down

0 comments on commit 79d25b0

Please sign in to comment.