Skip to content
CAI
Software that uses CAICheck a score

tokio-rs/tracing

71.8

Strong · 29 September 2026

49k

lines of production code

Rust

primary language

2

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a structured logging and diagnostics framework for Rust, centered on the \tracing\ crate which provides APIs for recording spans and events. It features a modular architecture via \tracing-subscriber\, allowing users to compose custom logging behaviors, format outputs, and apply granular per-layer filtering. The ecosystem extends this core with specialized crates for async instrumentation, file logging, error context capture, and integration with external systems like systemd-journald.

How it got here

2018–2019 — Workspace restructuring and modularization

34 changes.

The project reorganized into a Cargo workspace, removing legacy internal tracing infrastructure to establish a modular architecture centered on the new tracing-subscriber crate. This period introduced core features such as the \#\[instrument\] macro, async instrumentation via tracing-futures, and composable layer-based filtering, while adding supporting crates for serialization, logging bridges, and Tower middleware.

2020–2025 — New crates and layer filtering

19 changes.

This period focused on expanding the ecosystem with new dedicated crates for logging and profiling, including tracing-appender, tracing-flame, tracing-journald, and tracing-mock. Significant architectural work involved refactoring the core subscriber layer to support per-layer filtering and event short-circuiting. The work was accompanied by comprehensive test coverage and performance benchmarking to validate these new capabilities.

Features

Add \`trace\_dbg!\` and \`dbg!\` macros for tracing-based debugging

The \tracing-macros\ crate now provides \trace\_dbg!\ and \dbg!\ macros, which function similarly to the standard library's \dbg!\ macro but generate \tracing\ events instead of printing to stdout. This allows developers to debug expressions while integrating with the tracing ecosystem, with customizable log levels and targets.

tracing-macros/src · high confidence

Add chrono-based timestamp formatters

The \tracing-subscriber\ now includes \ChronoLocal\ and \ChronoUtc\ types in the \fmt::time\ module, allowing users to format log timestamps using the \chrono\ crate. These types support both RFC 3339 and custom format strings, providing an alternative to the existing \time\ crate and standard library time formatters.

tracing-subscriber/src/fmt/time · high confidence

Add factorial example demonstrating tracing macros

A new example file (factorial.rs) has been added to the tracing-macros examples directory. It demonstrates the usage of the \tracing\_macros::dbg\ macro within a recursive factorial function, showing how to integrate tracing with a subscriber setup using \tracing\_subscriber\ and an \EnvFilter\.

tracing-macros/examples · high confidence

Add sloggish example demonstrating a custom tree-structured subscriber

A new example named 'sloggish' has been added to the examples directory, demonstrating how to implement a custom tracing subscriber that produces a tree-structured log output similar to the 'compact' formatter in slog-term. The implementation uses nu-ansi-term for colored terminal output and thread-local storage to track span context, providing a reference for users building custom logging front-ends.

examples/examples/sloggish · high confidence

Add tracing-test crate for internal testing utilities

A new \tracing-test\ crate has been added to provide reusable utilities for testing \tracing\ and crates that use it. This crate is intended for internal use only; for mocks and expectations, users should refer to \tracing-mock\. The crate includes a \PollN\ future implementation for simulating polling behavior and a \block\_on\_future\ helper for synchronously awaiting futures in tests. It requires Rust 1.56+ and is licensed under MIT.

tracing-test · high confidence

Added executor support for futures 0.1 and 0.3

The \tracing-futures\ crate now provides executor integrations for both the legacy \futures\ 0.1 crate and the modern \futures\ 0.3 crate. This adds \Executor\ implementations for \Instrumented\ and \WithDispatch\ wrappers around \futures\ 0.1 executors, and \Spawn\/\LocalSpawn\ implementations for \futures\ 0.3 executors, allowing users to automatically instrument futures spawned on these executors. Tokio-specific extensions for \futures\ 0.1 are also included when the \tokio\ feature is enabled.

tracing-futures/src/executor · high confidence

Added internal spin-based synchronization primitives for no\_std support

The \tracing-core\ crate now includes vendored implementations of \Mutex\ and \Once\ synchronization primitives in \tracing-core/src/spin\. These provide spinning-based mutual exclusion and one-time initialization capabilities that do not depend on the standard library, enabling \tracing-core\ to function in \no\_std\ environments. The implementation includes a spinlock mutex with \lock\ and \try\_lock\ methods, and a thread-safe \Once\ primitive that supports initialization, waiting, and panic recovery.

tracing-core/src/spin · high confidence

Added yak\_shave example demonstrating mixed error handling with tracing

A new example file, yak\_shave.rs, has been added to the fmt examples directory. It demonstrates how to integrate the tracing library with error handling using both the snafu and thiserror crates. The example illustrates creating spans and events, recording error details, and chaining errors from different libraries within a single workflow.

examples/examples/fmt · high confidence

Builder API for RollingFileAppender configuration

A new \Builder\ struct has been introduced in \tracing-appender/src/rolling/builder.rs\ to configure \RollingFileAppender\ instances. This allows users to set specific parameters such as rotation strategy, filename prefixes and suffixes, a maximum file count limit, and an optional latest symlink, providing a more flexible and explicit way to construct rolling file appenders compared to previous methods.

tracing-appender/src/rolling · high confidence

Initial release of the \`fmt\` module for formatted tracing output

This change introduces the \tracing-subscriber::fmt\ module, providing a new \Layer\ that formats and logs \tracing\ events and spans as text. Users can now easily initialize a default formatted subscriber via \tracing\_subscriber::fmt::init()\ or construct custom layers with configurable formatters (such as \Full\, \Compact\, \Pretty\, and \Json\), writers, and field formatting options. The module includes abstractions for output destinations via the \MakeWriter\ trait and supports configuration of ANSI colors, thread IDs, and target names.

tracing-subscriber/src/fmt · high confidence

Initial release of the tracing structured logging framework

This change introduces the \tracing\ crate, a scoped, structured logging and diagnostics system for Rust. It provides core APIs for recording spans (periods of execution) and events (moments in time), along with a subscriber system for collecting trace data. Key features include compile-time level filtering via Cargo features, support for asynchronous code through \Future\ instrumentation, and integration with the \valuable\ crate for structured value recording.

tracing/src · high confidence

Initial release of tracing-futures for async instrumentation

This change introduces the \tracing-futures\ crate, providing utilities to attach \tracing\ spans and subscribers to asynchronous code. It adds the \Instrument\ trait to wrap futures, streams, and sinks with a specific span, and the \WithSubscriber\ trait to attach a subscriber context. The implementation supports both \std\ and \no\_std\ environments via feature flags and requires Rust 1.65 or later.

tracing-futures/src · high confidence

Initial release of tracing-serde for serializing tracing data

The \tracing-serde\ crate is introduced, providing an adapter to serialize \tracing\ types (such as \Event\, \Attributes\, \Record\, \Id\, and \Metadata\) into formats compatible with the \serde\ ecosystem. This enables users to implement custom \Subscriber\ implementations that output structured diagnostic data (e.g., JSON) for integration with distributed tracing systems or log aggregation tools. The crate requires Rust 1.65+ and includes support for serializing values recorded via the \valuable\ crate behind an unstable feature flag.

tracing-serde/src · high confidence

Initial release of tracing-subscriber 0.3

This entry introduces the \tracing-subscriber\ crate (version 0.3), providing a modular framework for composing \tracing\ subscribers. It adds the \Layer\ trait for building composable subscriber behaviors and the \Filter\ trait for per-layer filtering. The crate includes a \reload\ module that allows layers to be dynamically reconfigured at runtime, and utility traits like \SubscriberInitExt\ for ergonomic initialization. It supports \no\_std\ environments, optional \parking\_lot\ integration, and feature flags for \fmt\, \json\, and \env-filter\ capabilities.

tracing-subscriber/src · high confidence

Introduce Registry as a reusable span storage layer

The \tracing-subscriber\ crate now includes a \Registry\ type in the \registry\ module, which acts as a \Subscriber\ implementation that stores span data and exposes it to \Layer\s via the \LookupSpan\ trait. This change introduces a new \extensions\ typemap allowing layers to store and retrieve arbitrary per-span data, and implements the \Registry\ using a lock-free sharded slab for high-performance concurrent access. Users can now compose multiple layers on top of a \Registry\ to share span context and metadata, replacing the previous monolithic subscriber design with a modular architecture where the registry handles storage and layers handle behavior.

tracing-subscriber/src/registry · high confidence

Introduce \`\#\[instrument\]\` procedural macro for function tracing

The \tracing-attributes\ crate now provides the \\#\[instrument\]\ attribute, allowing users to automatically generate and enter \tracing\ spans for any function. This macro supports overriding span attributes such as \name\, \target\, and \level\, as well as controlling which arguments are recorded via \skip\ or \skip\_all\. It handles complex scenarios including \async\ functions, \async-trait\ implementations, and destructuring patterns, ensuring structured diagnostic information is collected with minimal boilerplate.

tracing-attributes/src · high confidence

Introduce per-layer filtering with Targets, FilterFn, and DynFilterFn

The \tracing-subscriber\ crate now supports per-layer filtering, allowing users to apply different filtering rules to individual layers rather than just globally. This change introduces the \Targets\ filter for static, target-prefix-based filtering (similar to \env\_logger\), and \FilterFn\/\DynFilterFn\ for custom logic, including dynamic filtering based on the current span context. These filters can be attached to specific layers using \with\_filter\, enabling granular control over what spans and events are recorded by each layer in the subscriber stack.

tracing-subscriber/src/filter · high confidence

Introduce tracing-appender for non-blocking and rolling file logging

The \tracing-appender\ crate is introduced, providing a \NonBlocking\ writer that offloads log writes to a dedicated worker thread to prevent blocking the application's data path, and a \RollingFileAppender\ that automatically rotates log files on a schedule (minutely, hourly, or daily). The non-blocking writer includes a configurable buffer limit and a \WorkerGuard\ to ensure buffered logs are flushed on process termination, while the rolling appender supports configuration via a builder pattern for filename prefixes, suffixes, and symlink management.

tracing-appender/src · high confidence

Introduce tracing-error crate for capturing span traces in errors

The new \tracing-error\ crate enables enriching Rust error handling with diagnostic information from \tracing\ span contexts. It provides \SpanTrace\, which captures the current span context (including fields and source locations) to help pinpoint where errors occurred, and \ErrorLayer\, a subscriber layer that enables this capture. Additionally, the \traced-error\ feature introduces \TracedError\, a wrapper type that bundles an error with a span trace, and extension traits like \InstrumentResult\ to easily attach span context to errors during propagation.

tracing-error/src · high confidence

Introduce tracing-flame crate for generating flamegraphs

Adds the new \tracing-flame\ crate, which provides a \FlameLayer\ for tracing subscribers. This layer records span open/close events as folded stack traces, allowing users to generate flamegraphs and flamecharts using the \inferno\ tool to visualize performance bottlenecks. The implementation includes error handling for file operations and requires Rust 1.65+.

tracing-flame/src · high confidence

Introduce tracing-journald layer for native systemd-journald integration

Adds the \tracing-journald\ crate, providing a \tracing\_subscriber::Layer\ that sends structured log events and spans directly to systemd-journald on Linux. The implementation supports custom syslog identifiers, configurable priority mappings between tracing levels and journald priorities, and automatic sanitization of field names to comply with journald conventions. It handles large payloads efficiently by using \memfd\_create\ for memory-backed file descriptors and communicates with the journal via unconnected Unix datagram sockets.

tracing-journald/src · high confidence

New automated release script for publishing crates

A new \bin/publish\ shell script has been added to automate the release process for workspace crates. The script verifies that the specified crate version matches the Cargo manifest, checks that the crate builds across its feature combinations (using \cargo-hack\ with specific exclusions for large feature sets like \tracing\), and then packages and publishes the crate to crates.io. It also handles git tagging and supports dry-run and verbose modes.

bin · high confidence

New builder API for EnvFilter with regex and default directive options

The \EnvFilter\ now exposes a \builder()\ method that returns a \Builder\ struct, allowing users to configure filtering behavior before parsing directives. This includes the ability to disable regular expression matching for field values (recommended for untrusted inputs) via \with\_regex\, and to set a fallback directive via \with\_default\_directive\ that is used when the parsed string or environment variable is empty or contains only invalid directives. The builder also supports customizing the environment variable name via \with\_env\_var\ and provides \parse\ (strict) and \parse\_lossy\ (ignoring invalid directives) methods to construct the final filter.

tracing-subscriber/src/filter/env · high confidence

New examples demonstrating tracing features and integrations

The examples/examples directory now includes a comprehensive suite of new demonstration programs. These cover core formatting options (compact, pretty, JSON, custom fields, source locations), async instrumentation with the \\#\[instrument\]\ macro, and advanced subscriber configurations like per-layer filtering and multi-writer output. The collection also introduces examples for specific integrations and tools, including \tracing-error\ for span traces on errors, \tracing-flame\ for flamegraph generation, \tracing-journald\ for systemd journal logging, and a TUI-based \env-filter-explorer\ for testing filter syntax.

examples/examples · high confidence

New field visitor abstraction and formatting wrappers

The \tracing-subscriber\ crate now exposes a \MakeVisitor\ abstraction for building composable field visitors, along with three new wrapper types: \Alt\ (formats \Debug\ fields using the alternate \{:\#?}\ style), \Messages\ (formats the \message\ field using \Display\), and \Delimited\ (inserts a configurable delimiter between formatted fields). These are accessible via the \MakeExt\ trait methods \debug\_alt()\, \display\_messages()\, and \delimited()\, allowing users to customize how trace fields are rendered in their subscribers.

tracing-subscriber/src/field · high confidence

New filter combinators for combining per-layer filters

Users can now combine multiple per-layer filters using logical operators. The \And\ combinator enables spans and events only if both underlying filters return true, while the \Or\ combinator enables them if either filter returns true. The \Not\ combinator inverts the result of a wrapped filter. These combinators are exposed via the \FilterExt\ trait methods \and\, \or\, and \not\, allowing for more complex filtering logic in individual layers.

_tracing-subscriber/src/filter/layer\filters · high confidence

New tracing-mock crate for validating trace expectations

A new \tracing-mock\ crate has been added to provide a mock subscriber and layer for testing \tracing\ instrumentation. This allows users to define specific expectations for spans, events, and fields, and then assert that the code under test produces the exact trace structure required. The crate includes an \ExpectedAncestry\ system to validate explicit and contextual parent relationships, a fluent API for constructing expectations via the \expect\ module, and a \MockLayer\ for integration with \tracing-subscriber\.

tracing-mock/src · high confidence

Performance optimization for log-to-tracing conversion via interest caching

The \tracing-log\ crate now includes an optional \interest-cache\ feature that significantly reduces the overhead of converting \log\ records into \tracing\ events. When enabled, this feature introduces an LRU cache that stores the interest status of log callsites (identified by target and level), preventing redundant checks against the tracing subscriber's filter. Users can configure the cache's minimum verbosity threshold and size via \InterestCacheConfig\ on the \LogTracer\ builder. This optimization is particularly beneficial for applications emitting high volumes of logs, as it minimizes the performance impact of filtering disabled log records.

tracing-log/src · high confidence

Removals

Removal of legacy tracing infrastructure

The \src\ directory's legacy tracing implementation has been removed. This includes the deletion of \src/lib.rs\, \src/dispatcher.rs\, and \src/subscriber.rs\, eliminating the previous \Dispatcher\, \Subscriber\ traits, and associated macro-based instrumentation APIs (\span!\, \event!\). Users relying on this internal tracing subsystem will no longer have access to these components, as the codebase has shifted away from this specific implementation.

src · high confidence

Security

Sanitize ANSI escape sequences in formatted log output

The \fmt\ formatters now include an \EscapeGuard\ wrapper that conditionally escapes ANSI escape sequences and C1 control characters in log messages. This prevents terminal injection attacks where malicious log content could manipulate the terminal display. The sanitization is controlled by the writer's ANSI configuration, ensuring that logs remain safe while preserving intended formatting when appropriate.

tracing-subscriber/src/fmt/format · high confidence

Behavioural changes

Examples directory restructured with new README and legacy code removal

The examples directory has been reorganized: a new README.md now documents the available examples across the tracing ecosystem (including tracing-subscriber, tracing-attributes, and tracing-futures), and the legacy basic.rs example using the deprecated tokio\_trace\_prototype crate has been removed.

examples · high confidence

Refactored layer composition and event filtering logic

The \tracing-subscriber\ layer module has been restructured to support per-layer filtering and improved event handling. The \Layered\ subscriber now implements \event\_enabled\ to allow layers to short-circuit event processing before the inner subscriber is queried, and it clears per-layer filter state when short-circuiting occurs. A new \Context\ struct provides layers with access to the current span and event parent information via \event\_span\, enabling more precise context-aware filtering. The \Layer\ trait methods have been renamed for consistency (e.g., \new\_span\ to \on\_new\_span\), and the \Layered\ type now correctly propagates \on\_register\_dispatch\ calls through the layer stack.

tracing-subscriber/src/layer · high confidence

Rewritten tracing-tower crate with new middleware and HTTP helpers

The tracing-tower crate has been rewritten to provide new middleware components for instrumenting Tower services. It introduces \request\_span\ and \service\_span\ modules, allowing users to attach tracing spans to individual requests or entire services via the \InstrumentableService\ trait and corresponding Tower layers. Additionally, a new \http\ module is added (behind the \http\ feature) that provides helper functions like \info\_request\, \debug\_request\, and \trace\_request\ to easily create spans from HTTP requests, capturing details such as method, URI, version, and headers.

tracing-tower/src · high confidence

tracing-core v0.1.22: Core primitives and dispatcher overhaul

This release updates the \tracing-core\ crate to version 0.1.22, introducing a comprehensive rewrite of the core tracing primitives and dispatcher architecture. The \Dispatch\ system now supports \WeakDispatch\ via \Dispatch::downgrade()\, allowing subscribers to hold non-owning references to avoid memory leaks. The callsite registry has been re-implemented to improve performance and stability, with changes to how \Interest\ is combined and cached. Additionally, the crate now requires Rust 1.65+ as the minimum supported version (MSRV), and includes various API additions such as \Subscriber::try\_close\, \Subscriber::current\_span\, and support for recording \valuable\ field values via an unstable feature flag.

tracing-core/src · high confidence

Test coverage

Added UI tests for tracing::instrument edge cases and regressions; Added benchmarking support infrastructure; Added benchmarks for span enter/exit, filtering, and formatting performance; Added comprehensive benchmark suite for tracing performance; Added comprehensive test coverage for tracing macros, filtering, and subscriber behavior; Added integration tests for the journald subscriber; Added performance benchmarks for synchronous and non-blocking appenders; Added test harness for verifying tracing-to-log integration; Added tests for ANSI sanitization and layer filtering behavior; Added tests for EnvFilter behavior; Added tests for LogTracer metadata normalization and log crate re-exports; Added tests for dispatcher lifecycle and callsite registration; Added tests for per-layer filtering capabilities; Added tests for span/event ancestry and layer dispatch propagation; Added tests for static max level filtering on events, spans, and instrumented functions; Added tests for tracing instrumentation of standard library futures; Added tests for tracing-flame integration; Expanded test coverage for the \#\[instrument\] macro.

Dependencies

Tracing workspace restructured and dependencies updated

The project has been reorganized into a Cargo workspace containing multiple crates (tracing, tracing-subscriber, tracing-appender, etc.) with updated dependency versions, including syn 2.0 for tracing-attributes, thiserror 2 for tracing-appender, and various updates to tracing-core, tracing-subscriber, and other internal dependencies.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 72 → 72 (-0.1)
  • Rubric changed (rubric-2026.09.9 → rubric-2026.09.18) — scores are not directly comparable.

Lenses

  • Code Health 93 → 93 (-0.0)
  • Architecture 100 → 99 (-0.7)
  • Maturity 67 → 67 (-0.1)
  • Readiness 68 → 71 (+3.8)
  • Security 71 → 71 (+0.0)
  • Performance 85 (new)

Resolved (2)

  • Documentation: no architecture or design documentation (tracing-flame/README.md)
  • Off-boarding risk: anonymized user #1

New (13)

  • Dependency hygiene PARTLY measured — Cargo dependencies read, no committed lock to grade for currency
  • Documentation: no installation or build instructions (README.md)
  • Documentation: no project overview (README.md)
  • Duplicate intent across modules with identical signatures. The Instrument trait and its in_current_span method are defined in both tracing::instrument and tracing_futures. While tracing_futures extends the behavior for futures, the base instrumentation logic is duplicated. Users importing both may face ambiguity or redundant trait implementations.
  • Duplicate intent across modules with identical signatures. The WithSubscriber trait and its methods are defined in both tracing::instrument and tracing_futures. This creates redundant trait definitions for the same functionality.
  • Duplicate type definition. Instrumented is defined in both tracing::instrument and tracing_futures with identical methods for accessing the span and inner value. This forces users to deal with two distinct types for the same concept.
  • Duplicate type definition. WithDispatch is defined in both tracing::instrument and tracing_futures with identical methods for accessing the inner value. This creates redundant types.
  • Duplicated block (12 lines × 2) (tracing-futures/src/lib.rs)
  • Inconsistent naming pattern for constructor variants. new vs new_with and new_root vs new_root_with suggests a pattern, but child_of and child_of_with also exist. The distinction between 'with' and without dispatch is clear, but the naming could be more uniform (e.g., always using a builder pattern or consistent suffixes). However, this is a minor stylistic issue.
  • Low cohesion: Instrumented (LCOM4 7) (tracing-futures/src/lib.rs)
  • Low cohesion: Tee (LCOM4 5) (tracing-subscriber/src/fmt/writer.rs)
  • Off the main sequence: tracing-core
  • Off-boarding risk: anonymized user #1

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

tokio-rs/tracing was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 29 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit d9d4c542de10f5d3a711b7a45ffe450fd0666437 — the exact code this score is about.
  • Scored under rubric-2026.09.18 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-c4983f2d4e5c.