tracing Documentation

Application level tracing for Rust.

0 stars Rust Rust 1 file ยท ~45,027 tokens
RAW Doc

Technical Documentation: MaterializeInc/tracing

โ„น๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference

Overview (`README.md`)

Tracing โ€” Structured, application-level diagnostics

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat

Website |
Chat | Documentation (master branch)

The master branch is the pre-release, development version of `tracing`. Please see the [v0.1.x](https://github.com/tokio-rs/tracing/tree/v0.1.x) branch for the versions of `tracing` released to crates.io.

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. tracing is maintained by the
Tokio project, but does not require the tokio runtime to be used.

Usage

In Applications

In order to record trace events, executables have to use a collector
implementation compatible with tracing. A collector implements a way of
collecting trace data, such as by logging it to standard output.
tracing-subscriber's fmt module provides
a collector for logging traces with reasonable defaults. Additionally,
tracing-subscriber is able to consume messages emitted by log-instrumented
libraries and modules.

To use tracing-subscriber, add the following to your Cargo.toml:

toml
[dependencies]
tracing = "0.1"
tracing-subscriber = "0.3"

Then create and install a collector, for example using init():

rust
use tracing::info;
use tracing_subscriber;

fn main() {
    // install global collector configured based on RUST_LOG env var.
    tracing_subscriber::fmt::init();

    let number_of_yaks = 3;
    // this creates a new event, outside of any spans.
    info!(number_of_yaks, "preparing to shave yaks");

    let number_shaved = yak_shave::shave_all(number_of_yaks);
    info!(
        all_yaks_shaved = number_shaved == number_of_yaks,
        "yak shaving completed."
    );
}

Using init() calls set_global_default() so this collector will be used
as the default in all threads for the remainder of the duration of the
program, similar to how loggers work in the log crate.

For more control, a collector can be built in stages and not set globally,
but instead used to locally override the default collector. For example:

rust
use tracing::{info, Level};
use tracing_subscriber;

fn main() {
    let collector = tracing_subscriber::fmt()
        // filter spans/events with level TRACE or higher.
        .with_max_level(Level::TRACE)
        // build but do not install the subscriber.
        .finish();

    tracing::collect::with_default(collector, || {
        info!("This will be logged to stdout");
    });
    info!("This will _not_ be logged to stdout");
}

Any trace events generated outside the context of a collector will not be collected.

This approach allows trace data to be collected by multiple collectors
within different contexts in the program. Note that the override only applies to the
currently executing thread; other threads will not see the change from with_default.

Once a collector has been set, instrumentation points may be added to the
executable using the tracing crate's macros.

In Libraries

Libraries should only rely on the tracing crate and use the provided macros
and types to collect whatever information might be useful to downstream consumers.

text
/* Detailed source-code truncated for AI context efficiency. */
toml
[dependencies]
tracing = "0.1"

Note: Libraries should NOT install a collector by using a method that calls
set_global_default(), as this will cause conflicts when executables try to
set the default later.

In Asynchronous Code

To trace async fns, the preferred method is using the #[instrument] attribute:

rust
use tracing::{info, instrument};
use tokio::{io::AsyncWriteExt, net::TcpStream};
use std::io;

#[instrument]
async fn write(stream: &mut TcpStream) -> io::Result<usize> {
    let result = stream.write(b"hello world\n").await;
    info!("wrote to stream; success={:?}", result.is_ok());
    result
}

Special handling is needed for the general case of code using
std::future::Future or blocks with async/await, as the
following example will not work:

rust
async {
    let _s = span.enter();
    // ...
}

The span guard _s will not exit until the future generated by the async block is complete.
Since futures and spans can be entered and exited multiple times without them completing,
the span remains entered for as long as the future exists, rather than being entered only when
it is polled, leading to very confusing and incorrect output.
For more details, see the documentation on closing spans.

This problem can be solved using the Future::instrument combinator:

rust
use tracing::Instrument;

let my_future = async {
    // ...
};

my_future
    .instrument(tracing::info_span!("my_future"))
    .await

Future::instrument attaches a span to the future, ensuring that the span's lifetime
is as long as the future's.

Under the hood, the #[instrument] macro performs the same explicit span
attachment that Future::instrument does.

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

Getting Help

First, see if the answer to your question can be found in the API documentation.
If the answer is not there, there is an active community in
the Tracing Discord channel. We would be happy to try to answer your
question. Last, if that doesn't work, try opening an issue with the question.

Contributing

:balloon: Thanks for your help improving the project! We are so happy to have
you! We have a contributing guide to help you get involved in the Tracing
project.

Project layout

The tracing crate contains the primary instrumentation API, used for
instrumenting libraries and applications to emit trace data. The tracing-core
crate contains the core API primitives on which the rest of tracing is
instrumented. Authors of trace subscribers may depend on tracing-core, which
guarantees a higher level of stability.

Additionally, this repository contains several compatibility and utility
libraries built on top of tracing. Some of these crates are in a pre-release
state, and are less stable than the tracing and tracing-core crates.

The crates included as part of Tracing are:

In addition to this repository, here are also several third-party crates which
are not maintained by the tokio project. These include:

  • tracing-timing implements inter-event timing metrics on top of tracing.
    It provides a subscriber that records the time elapsed between pairs of
    tracing events and generates histograms.
  • tracing-honeycomb Provides a layer that reports traces spanning multiple machines to honeycomb.io. Backed by tracing-distributed.
  • tracing-distributed Provides a generic implementation of a layer that reports traces spanning multiple machines to some backend.
  • tracing-actix-web provides tracing integration for the actix-web web framework.
  • tracing-actix provides tracing integration for the actix actor
    framework.
  • axum-insights provides tracing integration and Application insights export for the axum web framework.
  • tracing-gelf implements a subscriber for exporting traces in Greylog
    GELF format.
  • tracing-coz provides integration with the coz causal profiler
    (Linux-only).
  • tracing-bunyan-formatter provides a layer implementation that reports events and spans in bunyan format, enriched with timing information.
  • tide-tracing provides a tide middleware to trace all incoming requests and responses.
  • color-spantrace provides a formatter for rendering span traces in the
    style of color-backtrace
  • color-eyre provides customized panic and eyre report handlers for
    eyre::Report for capturing span traces and backtraces with new errors and
    pretty printing them.
  • spandoc provides a proc macro for constructing spans from doc comments
    inside of functions.
  • tracing-wasm provides a Collector/Subscriber implementation that reports
    events and spans via browser console.log and User Timing API (window.performance).
  • tracing-web provides a layer implementation of level-aware logging of events
    to web browsers' console.* and span events to the User Timing API (window.performance).
  • test-log takes care of initializing tracing for tests, based on
    environment variables with an env_logger compatible syntax.
  • tracing-unwrap provides convenience methods to report failed unwraps on Result or Option types to a Collector.
  • diesel-tracing provides integration with diesel database connections.
  • tracing-tracy provides a way to collect Tracy profiles in instrumented
    applications.
  • tracing-elastic-apm provides a layer for reporting traces to Elastic APM.
  • tracing-etw provides a layer for emitting Windows ETW events.
  • sentry-tracing provides a layer for reporting events and traces to Sentry.
  • tracing-forest provides a subscriber that preserves contextual coherence by
    grouping together logs from the same spans during writing.
  • tracing-loki provides a layer for shipping logs to Grafana Loki.
  • tracing-logfmt provides a layer that formats events and spans into the logfmt format.
  • tracing-chrome provides a layer that exports trace data that can be viewed in chrome://tracing.
  • reqwest-tracing provides a middleware to trace reqwest HTTP requests.
  • tracing-cloudwatch provides a layer that sends events to AWS CloudWatch Logs.
  • clippy-tracing provides a tool to add, remove and check for tracing::instrument.

(if you're the maintainer of a tracing ecosystem crate not in this list,
please let us know!)

Note: that some of the ecosystem crates are currently unreleased and
undergoing active development. They may be less stable than tracing and
tracing-core.

External Resources

This is a list of links to blog posts, conference talks, and tutorials about
Tracing.

Blog Posts

Talks

Help us expand this list! If you've written or spoken about Tracing, or
know of resources that aren't listed, please open a pull request adding them.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`examples/README.md`)

Tracing Examples

This directory contains a collection of examples that demonstrate the use of the
tracing ecosystem:

  • tracing:
    • counters: Implements a very simple metrics system to demonstrate how
      collectors can consume field values as typed data.
    • sloggish: A demo Collect implementation that mimics the output of
      slog-term's Compact formatter.
  • tracing-attributes:
    • attrs-basic: A simple example of the #[instrument] attribute.
    • attrs-literal-field-names: Demonstrates using literal field names rather
      than rust tokens..
    • attrs-args: An example implementing a simple recursive calculation of
      Fibonacci numbers, to demonstrate how the #[instrument] attribute can
      record function arguments.
  • tracing-subscriber:
    • fmt: Demonstrates the use of the fmt module in tracing-subscriber,
      which provides a collector implementation that logs traces to the console.
    • fmt-stderr: Demonstrates overriding the output stream used by the fmt
      collector.
    • fmt-custom-field: Demonstrates overriding how the fmt collector formats
      fields on spans and events.
    • fmt-custom-event: Demonstrates overriding how the fmt collector formats
      events.
    • fmt-multiple-writers.rs: demonstrates how fmt::Subcriber can write to multiple
      destinations (in this instance, stdout and a file) simultaneously.
    • fmt-source-locations.rs: demonstrates displaying source code locations
      with fmt::Subscriber.
    • subscriber-filter: Demonstrates the tracing-subscriber::filter module,
      which provides a subscriber which adds configurable filtering to a collector
      implementation.
    • tower-load: Demonstrates how dynamically reloadable filters can be used to
      debug a server under load in production.
    • journald: Demonstrates how to use fmt and journald subscribers to output to
      both the terminal and the system journal.
    • toggle-subscribers : Demonstrates how subscribers can be wrapped with an Option allowing
      them to be dynamically toggled.
  • tracing-futures:
    • spawny-thing: Demonstrates the use of the #[instrument] attribute macro
      asynchronous functions.
    • tokio-spawny-thing.rs: Similar to spawny-thingy, but with the additional
      demonstration instrumenting concurrent tasks created with
      tokio::spawn.
    • futures-proxy-server: Demonstrates the use of tracing-futures by
      implementing a simple proxy server, based on this example
      from tokio.
    • async_fn: Demonstrates how asynchronous functions can be
      instrumented.
    • echo: Demonstrates a tracing-instrumented variant of Tokio's echo example.
  • tracing-flame:
    • infero-flame: Demonstrates the use of tracing-flame to generate a flamegraph
      from spans.
  • tracing-tower:
    • tower-client: Demonstrates the use of tracing-tower to instrument a
      simple tower HTTP/1.1 client.
    • tower-server: Demonstrates the use of tracing-tower to instrument a
      simple tower HTTP/1.1 server.
  • tracing-serde:
    • serde-yak-shave: Demonstrates the use of tracing-serde by implementing a
      collector that emits trace output as JSON.
  • tracing-log:
    • hyper-echo: Demonstrates how tracing-log can be used to record
      unstructured logs from dependencies as tracing events, by instrumenting
      this example from hyper, and using tracing-log to record logs
      emitted by hyper.

Overview (`tracing-appender/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-appender

Writers for logging events and spans

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to
collect structured, event-based diagnostic information. tracing-appender
allows events and spans to be recorded in a non-blocking manner through a
dedicated logging thread. It also provides a RollingFileAppender
that can be used with or without the non-blocking writer.

Compiler support: requires rustc 1.53+

Usage

Add the following to your Cargo.toml:

toml
tracing-appender = "0.2"

This crate can be used in a few ways to record spans/events:

Rolling File Appender

rust
fn main(){
    let file_appender = tracing_appender::rolling::hourly("/some/directory", "prefix.log");
}

This creates an hourly rotating file appender that writes to
/some/directory/prefix.log.YYYY-MM-DD-HH. [Rotation::DAILY] and
[Rotation::NEVER] are the other available options.

The file appender implements std::io::Write. To be used with
tracing_subscriber::FmtSubscriber, it must be combined
with a MakeWriter implementation to be able to record
tracing spans/event.

The rolling module's documentation provides more detail on how to use
this file appender.

Non-Blocking Writer

The example below demonstrates the construction of a non_blocking writer
with an implementation of std::io::Writer.

rust
use std::io::Error;

struct TestWriter;

impl std::io::Write for TestWriter {
    fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
        let buf_len = buf.len();
    
        println!("{:?}", buf);
        Ok(buf_len)
    }

    fn flush(&mut self) -> std::io::Result<()> {
        Ok(())
    }
}

fn main() {
    let (non_blocking, _guard) = tracing_appender::non_blocking(TestWriter);
    tracing_subscriber::fmt().with_writer(non_blocking).init();
}

Note: _guard is a WorkerGuard which is returned by
tracing_appender::non_blocking to ensure buffered logs are flushed to
their output in the case of abrupt terminations of a process. See
WorkerGuard module for more details.

The example below demonstrates the construction of a
tracing_appender::non_blocking writer constructed with
a std::io::Write:

rust
fn main() {
    let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout());
    tracing_subscriber::fmt()
        .with_writer(non_blocking)
        .init();
}

The non_blocking module's documentation provides more detail on how to
use non_blocking.

Non-Blocking Rolling File Appender

rust
fn main() {
    let file_appender = tracing_appender::rolling::hourly("/some/directory", "prefix.log");
    let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
   tracing_subscriber::fmt()
       .with_writer(non_blocking)
       .init();
}

Supported Rust Versions

tracing-appender is built against the latest stable release. The minimum supported
version is 1.53. The current tracing-appender 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current
stable compiler version is 1.69, the minimum supported version will not be
increased past 1.66, three minor versions prior. Increasing the minimum
supported compiler version is not considered a semver breaking change as
long as doing so complies with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-attributes/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-attributes

Macro attributes for application-level tracing.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate provides the
#[instrument] attribute for automatically instrumenting functions using
tracing.

Note that this macro is also re-exported by the main tracing crate.

Compiler support: requires rustc 1.63+

Usage

First, add this to your Cargo.toml:

toml
[dependencies]
tracing-attributes = "0.1.11"

This crate provides the #[instrument] attribute for instrumenting a function
with a tracing span. For example:

rust
use tracing_attributes::instrument;

#[instrument]
pub fn my_function(my_arg: usize) {
    // ...
}

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-core/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-core

Core primitives for application-level tracing.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate defines the core
primitives of tracing.

The crate provides:

  • span::Id identifies a span within the execution of a program.

  • Event represents a single event within a trace.

  • Collect, the trait implemented to collect trace data.

  • Metadata and Callsite provide information describing spans and
    events.

  • Field, FieldSet, Value, and ValueSet represent the
    structured data attached to spans and events.

  • Dispatch allows spans and events to be dispatched to Subscribers.

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.63+

Usage

Application authors will typically not use this crate directly. Instead, they
will use the tracing crate, which provides a much more fully-featured
API. However, this crate's API will change very infrequently, so it may be used
when dependencies must be very stable.

Subscriber implementations may depend on tracing-core rather than tracing,
as the additional APIs provided by tracing are primarily useful for
instrumenting libraries and applications, and are generally not necessary for
Subscriber implementations.

Crate Feature Flags

The following crate feature flags are available:

  • std: Depend on the Rust standard library (enabled by default).

    no_std users may disable this feature with default-features = false:

    toml
    [dependencies]
    tracing-core = { version = "0.1.17", default-features = false }

    Note:tracing-core's no_std support requires liballoc.

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.69, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-error/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-error

Utilities for enriching error handling with tracing diagnostic
information.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat
maintenance status

Documentation (release) | Documentation (master) | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
scoped, structured, and async-aware diagnostics. This crate provides
integrations between tracing instrumentation and Rust error handling. It
enables enriching error types with diagnostic information from tracing
span contexts, formatting those contexts when errors are displayed, and
automatically generate tracing events when errors occur.

The crate provides the following:

Note: This crate is currently experimental.

Compiler support: requires rustc 1.63+

Usage

tracing-error provides the SpanTrace type, which captures the current
tracing span context when it is constructed and allows it to be displayed
at a later time.

For example:

rust
use std::{fmt, error::Error};
use tracing_error::SpanTrace;

#[derive(Debug)]
pub struct MyError {
    context: SpanTrace,
    // ...
}

impl fmt::Display for MyError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        // ... format other parts of the error ...

        self.context.fmt(f)?;

        // ... format other error context information, cause chain, etc ...
        # Ok(())
    }
}

impl Error for MyError {}

impl MyError {
    pub fn new() -> Self {
        Self {
            context: SpanTrace::capture(),
            // ... other error information ...
        }
    }
}

This crate also provides TracedError, for attaching a SpanTrace to an
existing error. The easiest way to wrap errors in TracedError is to either
use the InstrumentResult and InstrumentError traits or the From/Into
traits.

rust
use tracing_error::prelude::*;

std::fs::read_to_string("myfile.txt").in_current_span()?;

Once an error has been wrapped with with a TracedError, the SpanTrace
can be extracted one of three ways: either via TracedError's
Display/Debug implementations, or via the ExtractSpanTrace trait.

For example, here is how one might print the errors but specialize the
printing when the error is a placeholder for a wrapping SpanTrace:

rust
use std::error::Error;
use tracing_error::ExtractSpanTrace as _;

fn print_extracted_spantraces(error: &(dyn Error + 'static)) {
    let mut error = Some(error);
    let mut ind = 0;

    eprintln!("Error:");

    while let Some(err) = error {
        if let Some(spantrace) = err.span_trace() {
            eprintln!("found a spantrace:\n{}", spantrace);
        } else {
            eprintln!("{:>4}: {}", ind, err);
        }

        error = err.source();
        ind += 1;
    }
}

Whereas here, we can still display the content of the SpanTraces without
any special casing by simply printing all errors in our error chain.

rust
use std::error::Error;

fn print_naive_spantraces(error: &(dyn Error + 'static)) {
    let mut error = Some(error);
    let mut ind = 0;

    eprintln!("Error:");

    while let Some(err) = error {
        eprintln!("{:>4}: {}", ind, err);
        error = err.source();
        ind += 1;
    }
}

Applications that wish to use tracing-error-enabled errors should
construct an ErrorSubscriber and add it to their Subscriber in order to
enable capturing SpanTraces. For example:

rust
use tracing_error::ErrorSubscriber;
use tracing_subscriber::prelude::*;

fn main() {
    let subscriber = tracing_subscriber::Registry::default()
        // any number of other subscriber layers may be added before or
        // after the `ErrorSubscriber`...
        .with(ErrorSubscriber::default());

    // set the subscriber as the default for the application
    tracing::subscriber::set_global_default(subscriber);
}

Feature Flags

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

In addition to this repository, here are also several third-party crates which
are not maintained by the tokio project. These include:

  • color-spantrace provides a formatter for rendering SpanTrace in the style
    of color-backtrace
  • color-eyre provides a customized version of eyre::Report for capturing
    span traces and backtraces with new errors and pretty printing them in error
    reports.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-flame/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-flame

A tracing Layer for generating a folded stack trace for generating flamegraphs
and flamecharts with inferno

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat
maintenance status

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
scoped, structured, and async-aware diagnostics. tracing-flame provides helpers
for consuming tracing instrumentation that can later be visualized as a
flamegraph/flamechart. Flamegraphs/flamecharts are useful for identifying performance
bottlenecks in an application. For more details, see Brendan Gregg's post
on flamegraphs.

Compiler support: requires rustc 1.63+

Usage

This crate is meant to be used in a two step process:

  1. Capture textual representation of the spans that are entered and exited
    with FlameLayer.
  2. Feed the textual representation into inferno-flamegraph to generate the
    flamegraph or flamechart.

Note: when using a buffered writer as the writer for a FlameLayer, it is necessary to
ensure that the buffer has been flushed before the data is passed into
inferno-flamegraph. For more details on how to flush the internal writer
of the FlameLayer, see the docs for FlushGuard.

Layer Setup

rust
use tracing_flame::FlameLayer;
use tracing_subscriber::{prelude::*, fmt};

fn setup_global_subscriber() -> impl Drop {
    let fmt_layer = fmt::Layer::default();

    let (flame_layer, _guard) = FlameLayer::with_file("./tracing.folded").unwrap();

    tracing_subscriber::registry()
        .with(fmt_layer)
        .with(flame_layer)
        .init();
    _guard
}

// your code here ..

As an alternative, you can provide any type that implements std::io::Write to
FlameLayer::new.

Generating the Image

To convert the textual representation of a flamegraph to a visual one, first install inferno:

console
cargo install inferno

Then, pass the file created by FlameLayer into inferno-flamegraph:

console
# flamegraph
cat tracing.folded | inferno-flamegraph > tracing-flamegraph.svg

# flamechart
cat tracing.folded | inferno-flamegraph --flamechart > tracing-flamechart.svg

Differences between `flamegraph`s and `flamechart`s

By default, inferno-flamegraph creates flamegraphs. Flamegraphs operate by
that collapsing identical stack frames and sorting them on the frame's names.

This behavior is great for multithreaded programs and long-running programs
where the same frames occur many times, for short durations, because it reduces
noise in the graph and gives the reader a better idea of the
overall time spent in each part of the application.

However, it is sometimes desirable to preserve the exact ordering of events
as they were emitted by tracing-flame, so that it is clear when each
span is entered relative to others and get an accurate visual trace of
the execution of your program. This representation is best created with a
flamechart, which does not sort or collapse identical stack frames.

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-futures/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-futures

Utilities for instrumenting futures-based code with tracing.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat
maintenance status

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. This crate provides utilities
for using tracing to instrument asynchronous code written using futures and
async/await.

The crate provides the following traits:

Compiler support: requires rustc 1.63+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-journald/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-journald

Support for logging tracing events natively to journald,
preserving structured information.

Crates.io
Documentation (master)
MIT licensed
maintenance status

Overview

tracing is a framework for instrumenting Rust programs to collect
scoped, structured, and async-aware diagnostics. tracing-journald provides a
tracing-subscriber::Layer implementation for logging tracing spans
and events to systemd-journald, on Linux distributions that use
systemd.

Compiler support: requires rustc 1.63+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-log/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-log

log compatibility for tracing.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat
maintenance status

Documentation | Chat (discord)

Overview

tracing is a framework for instrumenting Rust programs with context-aware,
structured, event-based diagnostic information. This crate provides
compatibility layers for using tracing alongside the logging facade provided
by the log crate.

This crate provides:

Compiler support: requires rustc 1.63+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-mock/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-mock

Utilities for testing tracing and crates that uses it.

Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. tracing-mock provides
tools for making assertions about what tracing diagnostics are emitted
by code under test.

Compiler support: requires rustc 1.63+

Usage

tracing-mock crate provides a mock
Collector
that allows asserting on the order and contents of
spans and
events.

As tracing-mock isn't available on crates.io
yet, you must import it via git. When using tracing-mock with the
tracing 0.1 ecosystem, it is important that you also override the
source of any tracing crates that are transient dependencies. For
example, the Cargo.toml for your test crate could contain:

toml
[dependencies]
lib-under-test = "1.0" # depends on `tracing`

[dev-dependencies]
tracing-mock = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x", version = "0.1" }
tracing = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x", version = "0.1" }

[patch.crates-io]
tracing = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x" }
tracing-core = { git = "https://github.com/tokio-rs/tracing", branch = "v0.1.x" }

Examples

The following examples are for the master branch. For examples that
will work with tracing from [crates.io], please check the
v0.1.x
branch.

Below is an example that checks that an event contains a message:

rust
use tracing::collect::with_default;
use tracing_mock::{collector, expect};

fn yak_shaving() {
    tracing::info!("preparing to shave yaks");
}

let (collector, handle) = collector::mock()
    .event(expect::event().with_fields(expect::message("preparing to shave yaks")))
    .only()
    .run_with_handle();

with_default(collector, || {
    yak_shaving();
});

handle.assert_finished();

Below is a slightly more complex example. tracing-mock asserts that, in order:

  • a span is created with a single field/value pair
  • the span is entered
  • an event is created with the field number_of_yaks, a corresponding
    value of 3, and the message "preparing to shave yaks", and nothing else
  • an event is created with the field all_yaks_shaved, a corresponding value
    of true, and the message "yak shaving completed"
  • the span is exited
  • no further traces are received
rust
use tracing::collect::with_default;
use tracing_mock::{collector, expect};

#[tracing::instrument]
fn yak_shaving(number_of_yaks: u32) {
    tracing::info!(number_of_yaks, "preparing to shave yaks");

    let number_shaved = number_of_yaks; // shave_all
    tracing::info!(
        all_yaks_shaved = number_shaved == number_of_yaks,
        "yak shaving completed."
    );
}

let yak_count: u32 = 3;
let span = expect::span().named("yak_shaving");

let (collector, handle) = collector::mock()
    .new_span(
        span.clone()
            .with_fields(expect::field("number_of_yaks").with_value(&yak_count).only()),
    )
    .enter(span.clone())
    .event(
        expect::event().with_fields(
            expect::field("number_of_yaks")
                .with_value(&yak_count)
                .and(expect::message("preparing to shave yaks"))
                .only(),
        ),
    )
    .event(
        expect::event().with_fields(
            expect::field("all_yaks_shaved")
                .with_value(&true)
                .and(expect::message("yak shaving completed."))
                .only(),
        ),
    )
    .exit(span.clone())
    .only()
    .run_with_handle();

with_default(collector, || {
    yak_shaving(yak_count);
});

handle.assert_finished();

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-serde/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-serde

An adapter for serializing tracing types using serde.

Documentation
Documentation (master)

Overview

tracing is a framework for instrumenting Rust programs to collect
scoped, structured, and async-aware diagnostics.tracing-serde enables
serializing tracing types using serde.

Traditional logging is based on human-readable text messages.
tracing gives us machine-readable structured diagnostic
information. This lets us interact with diagnostic data
programmatically. With tracing-serde, you can implement a
Subscriber to serialize your tracing types and make use of the
existing ecosystem of serde serializers to talk with distributed
tracing systems.

Serializing diagnostic information allows us to do more with our logged
values. For instance, when working with logging data in JSON gives us
pretty-print when we're debugging in development and you can emit JSON
and tracing data to monitor your services in production.

The tracing crate provides the APIs necessary for instrumenting
libraries and applications to emit trace data.

Compiler support: requires rustc 1.63+

Usage

First, add this to your Cargo.toml:

toml
[dependencies]
tracing = "0.1"
tracing-serde = "0.1"

Next, add this to your crate:

rust
use tracing_serde::AsSerde;

Please read the tracing documentation
for more information on how to create trace data.

This crate provides the as_serde function, via the AsSerde trait,
which enables serializing the Attributes, Event, Id, Metadata,
and Record tracing values.

For the full example, please see the examples folder.

Implement a Subscriber to format the serialization of tracing
types how you'd like.

rust
pub struct JsonSubscriber {
    next_id: AtomicUsize, // you need to assign span IDs, so you need a counter
}

impl Subscriber for JsonSubscriber {

    fn new_span(&self, attrs: &Attributes) -> Id {
        let id = self.next_id.fetch_add(1, Ordering::Relaxed);
        let id = Id::from_u64(id as u64);
        let json = json!({
        "new_span": {
            "attributes": attrs.as_serde(),
            "id": id.as_serde(),
        }});
        println!("{}", json);
        id
    }
    // ...
}

After you implement your Subscriber, you can use your tracing
subscriber (JsonSubscriber in the above example) to record serialized
trace data.

Crate Feature Flags

The following crate feature flags are available:

  • std: Depend on the Rust standard library (enabled by default).

    no_std users may disable this feature with default-features = false:

    toml
    [dependencies]
    tracing-serde = { version = "0.2", default-features = false }

    Note:tracing-serde's no_std support requires liballoc.

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-subscriber/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-subscriber

Utilities for implementing and composing tracing subscribers.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat
maintenance status

Documentation | Chat

Compiler support: requires rustc 1.63+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing-test/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing-test

Utilities for testing tracing and crates that uses it.

Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information. tracing-test provides
some reusable tools to aid in testing, but that are only intended for
internal use. For mocks and expectations, see [tracing-mock].

Compiler support: requires rustc 1.56+

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.56. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.45, the minimum supported version will not be increased
past 1.42, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tracing by you, shall be licensed as MIT, without any additional
terms or conditions.


Overview (`tracing/README.md`)

Tracing โ€” Structured, application-level diagnostics

tracing

Application-level tracing for Rust.

Crates.io
Documentation
Documentation (master)
MIT licensed
Build Status
Discord chat

Documentation | Chat

Overview

tracing is a framework for instrumenting Rust programs to collect
structured, event-based diagnostic information.

In asynchronous systems like Tokio, interpreting traditional log messages can
often be quite challenging. Since individual tasks are multiplexed on the same
thread, associated events and log lines are intermixed making it difficult to
trace the logic flow. tracing expands upon logging-style diagnostics by
allowing libraries and applications to record structured events with additional
information about temporality and causality โ€” unlike a log message, a span
in tracing has a beginning and end time, may be entered and exited by the
flow of execution, and may exist within a nested tree of similar spans. In
addition, tracing spans are structured, with the ability to record typed
data as well as textual messages.

The tracing crate provides the APIs necessary for instrumenting libraries
and applications to emit trace data.

Compiler support: requires rustc 1.63+

Usage

(The examples below are borrowed from the log crate's yak-shaving
example, modified to
idiomatic tracing.)

In Applications

In order to record trace events, executables have to use a Subscriber
implementation compatible with tracing. A Subscriber implements a way of
collecting trace data, such as by logging it to standard output. tracing_subscriber's
fmt module provides reasonable defaults.
Additionally, tracing-subscriber is able to consume messages emitted by log-instrumented libraries and modules.

The simplest way to use a subscriber is to call the set_global_default function.

rust
use tracing::{info, Level};
use tracing_subscriber::FmtSubscriber;

fn main() {
    // a builder for `FmtSubscriber`.
    let subscriber = FmtSubscriber::builder()
        // all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
        // will be written to stdout.
        .with_max_level(Level::TRACE)
        // completes the builder.
        .finish();

    tracing::subscriber::set_global_default(subscriber)
        .expect("setting default subscriber failed");

    let number_of_yaks = 3;
    // this creates a new event, outside of any spans.
    info!(number_of_yaks, "preparing to shave yaks");

    let number_shaved = yak_shave::shave_all(number_of_yaks);
    info!(
        all_yaks_shaved = number_shaved == number_of_yaks,
        "yak shaving completed."
    );
}
toml
[dependencies]
tracing = "0.1"
tracing-subscriber = "0.2.0"

This subscriber will be used as the default in all threads for the remainder of the duration
of the program, similar to how loggers work in the log crate.

In addition, you can locally override the default subscriber. For example:

rust
use tracing::{info, Level};
use tracing_subscriber::FmtSubscriber;

fn main() {
    let subscriber = tracing_subscriber::FmtSubscriber::builder()
        // all spans/events with a level higher than TRACE (e.g, debug, info, warn, etc.)
        // will be written to stdout.
        .with_max_level(Level::TRACE)
        // builds the subscriber.
        .finish();

    tracing::subscriber::with_default(subscriber, || {
        info!("This will be logged to stdout");
    });
    info!("This will _not_ be logged to stdout");
}

This approach allows trace data to be collected by multiple subscribers
within different contexts in the program. Note that the override only applies to the
currently executing thread; other threads will not see the change from with_default.

Any trace events generated outside the context of a subscriber will not be collected.

Once a subscriber has been set, instrumentation points may be added to the
executable using the tracing crate's macros.

In Libraries

Libraries should only rely on the tracing crate and use the provided macros
and types to collect whatever information might be useful to downstream consumers.

text
/* Detailed source-code truncated for AI context efficiency. */
toml
[dependencies]
tracing = "0.1"

Note: Libraries should NOT call set_global_default(), as this will cause
conflicts when executables try to set the default later.

In Asynchronous Code

If you are instrumenting code that make use of
std::future::Future
or async/await, avoid using the Span::enter method. The following example
will not work:

rust
async {
    let _s = span.enter();
    // ...
}

The span guard _s will not exit until the future generated by the async block is complete.
Since futures and spans can be entered and exited multiple times without them completing,
the span remains entered for as long as the future exists, rather than being entered only when
it is polled, leading to very confusing and incorrect output.
For more details, see the documentation on closing spans.

There are two ways to instrument asynchronous code. The first is through the
Future::instrument combinator:

rust
use tracing::Instrument;

let my_future = async {
    // ...
};

my_future
    .instrument(tracing::info_span!("my_future"))
    .await

Future::instrument attaches a span to the future, ensuring that the span's lifetime
is as long as the future's.

The second, and preferred, option is through the
#[instrument]
attribute:

rust
use tracing::{info, instrument};
use tokio::{io::AsyncWriteExt, net::TcpStream};
use std::io;

#[instrument]
async fn write(stream: &mut TcpStream) -> io::Result<usize> {
    let result = stream.write(b"hello world\n").await;
    info!("wrote to stream; success={:?}", result.is_ok());
    result
}

Under the hood, the #[instrument] macro performs the same explicit span
attachment that Future::instrument does.

Concepts

This crate provides macros for creating Spans and Events, which represent
periods of time and momentary events within the execution of a program,
respectively.

As a rule of thumb, spans should be used to represent discrete units of work
(e.g., a given request's lifetime in a server) or periods of time spent in a
given context (e.g., time spent interacting with an instance of an external
system, such as a database). In contrast, events should be used to represent
points in time within a span โ€” a request returned with a given status code,
n new items were taken from a queue, and so on.

Spans are constructed using the span! macro, and then entered
to indicate that some code takes place within the context of that Span:

rust
use tracing::{span, Level};

// Construct a new span named "my span".
let mut span = span!(Level::INFO, "my span");
span.in_scope(|| {
    // Any trace events in this closure or code called by it will occur within
    // the span.
});
// Dropping the span will close it, indicating that it has ended.

The #[instrument] attribute macro
can reduce some of this boilerplate:

rust
use tracing::{instrument};

#[instrument]
pub fn my_function(my_arg: usize) {
    // This event will be recorded inside a span named `my_function` with the
    // field `my_arg`.
    tracing::info!("inside my_function!");
    // ...
}

The Event type represent an event that occurs instantaneously, and is
essentially a Span that cannot be entered. They are created using the event!
macro:

rust
use tracing::{event, Level};

event!(Level::INFO, "something has happened!");

Users of the log crate should note that tracing exposes a set of macros for
creating Events (trace!, debug!, info!, warn!, and error!) which may
be invoked with the same syntax as the similarly-named macros from the log
crate. Often, the process of converting a project to use tracing can begin
with a simple drop-in replacement.

Ecosystem

In addition to tracing and tracing-core, the tokio-rs/tracing repository
contains several additional crates designed to be used with the tracing ecosystem.
This includes a collection of Subscriber implementations, as well as utility
and adapter crates to assist in writing Subscribers and instrumenting
applications.

In particular, the following crates are likely to be of interest:

  • tracing-futures provides a compatibility layer with the futures
    crate, allowing spans to be attached to Futures, Streams, and Executors.
  • tracing-subscriber provides Subscriber implementations and
    utilities for working with Subscribers. This includes a FmtSubscriber
    FmtSubscriber for logging formatted trace data to stdout, with similar
    filtering and formatting to the env_logger crate.
  • tracing-log provides a compatibility layer with the log crate,
    allowing log messages to be recorded as tracing Events within the
    trace tree. This is useful when a project using tracing have
    dependencies which use log. Note that if you're using
    tracing-subscriber's FmtSubscriber, you don't need to depend on
    tracing-log directly.
  • tracing-opentelemetry: Provides a layer that connects spans from multiple
    systems into a trace and emits them to OpenTelemetry-compatible distributed
    tracing systems for processing and visualization.

Additionally, there are also several third-party crates which are not
maintained by the tokio project. These include:

  • tracing-timing implements inter-event timing metrics on top of tracing.
    It provides a subscriber that records the time elapsed between pairs of
    tracing events and generates histograms.
  • tracing-honeycomb Provides a layer that reports traces spanning multiple machines to honeycomb.io. Backed by tracing-distributed.
  • tracing-distributed Provides a generic implementation of a layer that reports traces spanning multiple machines to some backend.
  • tracing-actix provides tracing integration for the actix actor
    framework.
  • axum-insights provides tracing integration and Application insights export for the axum web framework.
  • tracing-gelf implements a subscriber for exporting traces in Greylog
    GELF format.
  • tracing-coz provides integration with the coz causal profiler
    (Linux-only).
  • test-log takes care of initializing tracing for tests, based on
    environment variables with an env_logger compatible syntax.
  • tracing-unwrap provides convenience methods to report failed unwraps on Result or Option types to a Subscriber.
  • diesel-tracing provides integration with diesel database connections.
  • tracing-tracy provides a way to collect Tracy profiles in instrumented
    applications.
  • tracing-elastic-apm provides a layer for reporting traces to Elastic APM.
  • tracing-etw provides a layer for emitting Windows ETW events.
  • tracing-fluent-assertions provides a fluent assertions-style testing
    framework for validating the behavior of tracing spans.
  • sentry-tracing provides a layer for reporting events and traces to Sentry.
  • tracing-loki provides a layer for shipping logs to Grafana Loki.
  • tracing-logfmt provides a layer that formats events and spans into the logfmt format.

If you're the maintainer of a tracing ecosystem crate not listed above,
please let us know! We'd love to add your project to the list!

Note: that some of the ecosystem crates are currently unreleased and
undergoing active development. They may be less stable than tracing and
tracing-core.

Supported Rust Versions

Tracing is built against the latest stable release. The minimum supported
version is 1.63. 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
project. The current stable Rust compiler and the three most recent minor
versions before it will always be supported. For example, if the current stable
compiler version is 1.69, the minimum supported version will not be increased
past 1.66, three minor versions prior. Increasing the minimum supported compiler
version is not considered a semver breaking change as long as doing so complies
with this policy.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.


--- METRICS ---