Skip to main content

Structured Logging and Tracing with the tracing Crate

The tracing crate is Rust's defacto standard for structured observability: collecting and querying diagnostic events (logs, traces, metrics) from your applications in a composable, zero-copy, and context-preserving way. Unlike traditional printf-style logging, tracing lets you emit events within hierarchical scopes called spans, attach arbitrary structured data to each event, and dynamically filter what you observe without recompiling your code.

This series takes you from first principles—understanding what spans and events are, why context matters—through production patterns: building custom subscribers, JSON output, filtering, instrumenting async code, and integrating with observability platforms. By the end, you'll be able to write Rust applications whose runtime behavior is fully observable without sacrificing performance or adding boilerplate.

Articles in This Series

  1. What Is the Rust tracing Crate and Why You Need It
  2. Getting Started with Tracing Spans and Events in Rust
  3. Using Tracing Macros: span!, info!, debug!, and More
  4. Building Subscribers for Custom Logging Behavior
  5. Structured Logging with JSON Output in Rust
  6. Filtering Logs by Level, Target, and Span in Rust
  7. Instrumenting Async Code Without Losing Context
  8. Creating Hierarchical Spans and Context in Tracing
  9. Performance Tuning Your Tracing Subscriber
  10. Integrating Tracing with Third-Party Observability Platforms