tracing-rust

Instrument Rust applications with tracing spans, events, subscribers, and structured logging.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill tracing-rust-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tracing-rust
Source: https://github.com/avbel/ai-skills/tree/main/skills/tracing-rust
Command: npx skills add https://github.com/avbel/ai-skills --skill tracing-rust-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust developers often struggle to add consistent, structured observability to their applications, ending up with ad-hoc println debugging or misused tracing patterns like entering spans across await points. This Skill encodes the idiomatic conventions for the tokio-rs tracing ecosystem so instrumentation is correct from the start. ## Core Features & Use Cases - Span and Event Instrumentation: Covers the #[instrument] attribute, manual span creation, field sigils (% and ?), and async instrumentation with .instrument(). - Subscriber Configuration: Shows fmt subscriber setup, EnvFilter with RUST_LOG, JSON output, layered registries, and tokio-console integration. - Structured Error Logging: Enforces structured error fields (error = ?e) instead of stringified messages, plus production guidance like release_max_level_info. - Use Case: When adding observability to an axum or tokio service, use this Skill to instrument handlers with #[instrument], configure an env-filtered JSON subscriber, and avoid common async pitfalls. ## Quick Start Instrument my Rust async handlers with tracing spans and set up a JSON subscriber filtered by the RUST_LOG environment variable.

Frequently Asked Questions about tracing-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add tracing instrumentation to Rust async functions?▼

Add the #[instrument] attribute from the tracing crate to automatically create a span from the function name and arguments. Use skip() for large or sensitive parameters, and never call span.enter() across .await points—use .instrument() on futures instead.

How to set up tracing-subscriber with RUST_LOG filtering?▼

Build an EnvFilter with EnvFilter::try_from_default_env() and pass it to tracing_subscriber::fmt().with_env_filter(filter).init(). This reads the RUST_LOG variable, supporting per-module directives like my_app=debug,sqlx=warn.

What is the difference between % and ? sigils in tracing macros?▼

The % sigil formats fields with Display, suited for strings and numbers, while ? uses Debug, suited for structs, enums, and errors. No sigil defaults to Display for numbers and Debug for other types.

Does tracing work with tokio-console for async debugging?▼

Yes, add console-subscriber as a dependency and call console_subscriber::init() in main. Enable tracing's release_max_level_info feature in production builds to limit overhead while keeping tokio-console support during development.

Why is my tracing output empty in Rust?▼

Tracing produces no output without an initialized subscriber. Call tracing_subscriber::fmt::init() early in main; without it, all spans and events are no-ops. Also verify RUST_LOG is not filtering out your target module.

When should I avoid high-cardinality fields in tracing spans?▼

Avoid high-cardinality fields like per-request IDs in span-level fields within hot loops, since each unique value creates a new span identity and increases overhead. Record such values on events instead of spans.