rust-tracing
БесплатноБез исполняемых скриптовНе проверенRust `tracing` crate — structured, async-aware diagnostics. Spans, events, fields, instrument macro, subscribers (fmt, JSON, OpenTelemetry, Tokio Console)…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Rust tracing — Structured Diagnostics
Deep Knowledge: Use
mcp__documentation__fetch_docswith technology:tracing.
Why tracing Over log
| Aspect | log crate |
tracing |
|---|---|---|
| Granularity | Single events | Events + spans (nested context) |
| Async-aware | ❌ Loses context across .await |
✅ Span context follows tasks |
| Structured fields | ❌ String-only | ✅ Typed key-value |
| Multiple subscribers | One global | Composable layers |
| Sampling/filtering | Global level | Per-target, per-field, dynamic |
| OpenTelemetry | Manual bridge | First-class via tracing-opentelemetry |
| Tokio integration | None | Tokio Console for live debugging |
For modern Rust async services and wallet apps: tracing.
Setup
[dependencies]
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "json", "fmt"] }
# Optional
tracing-appender = "0.2" # rolling file output
tracing-opentelemetry = "0.27" # OTel export
opentelemetry = "0.26"
opentelemetry_sdk = "0.26"
opentelemetry-otlp = "0.26"
console-subscriber = "0.4" # tokio-console
Initialize Subscriber
use tracing_subscriber::{fmt, EnvFilter, prelude::*};
fn init_tracing() {
tracing_subscriber::registry()
.with(EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info")))
.with(fmt::layer().with_target(true).with_line_number(true))
.init();
}
fn main() {
init_tracing();
tracing::info!("started");
}
Filter via env:
RUST_LOG=info cargo run # default level info
RUST_LOG=debug cargo run # debug everything
RUST_LOG=bhodl=debug,tower=info cargo run # per-crate
RUST_LOG="bhodl::wallet=trace" cargo run # per-module
Events (Like Log Lines)
use tracing::{trace, debug, info, warn, error};
info!("server started");
warn!("retrying after error");
error!("send failed");
// With fields (structured)
info!(user_id = 42, action = "login", "user authenticated");
warn!(retry_count = 3, ?error, "retry exhausted"); // ?error = Debug format
error!(%error, "send failed"); // %error = Display format
// Conditional formatting
debug!(target: "payments", amount_sats = 1000, "payment initiated");
Output (default fmt layer):
2026-05-04T10:00:00.123456Z INFO bhodl::auth: user authenticated user_id=42 action=login
2026-05-04T10:00:01.123456Z WARN bhodl::sync: retry exhausted retry_count=3 error=ConnectionError
Spans (Nested Context)
use tracing::{info_span, instrument};
fn process_request(req: Request) {
let span = info_span!("process_request", request_id = %req.id, method = req.method);
let _enter = span.enter();
info!("validating");
validate(&req);
info!("storing");
store(&req);
} // span exits here
// All `info!` inside the span are tagged with request_id and method
#[instrument] Attribute (Idiomatic)
use tracing::instrument;
#[instrument(skip(repo), fields(wallet_id = %wallet.id))]
async fn sync_wallet(wallet: &Wallet, repo: &Repo) -> Result<()> {
info!("syncing");
let txs = repo.fetch_transactions(&wallet.id).await?;
info!(count = txs.len(), "fetched transactions");
repo.save_transactions(txs).await?;
Ok(())
}
skip(repo) excludes repo from instrumented fields (often big or non-Display).
fields(wallet_id = %wallet.id) adds custom fields not from arguments.
Async-aware: span context survives .await boundaries automatically.
Span on Result
#[instrument(err)]
async fn risky() -> Result<(), MyError> {
// returns Err — auto-logged at error level
Err(MyError::Boom)
}
#[instrument(ret)]
async fn computes() -> u64 {
// returns Ok(42) — auto-logged
42
}
#[instrument(level = "debug", skip_all, fields(user_id = %user.id))]
async fn detailed(user: &User) { /* ... */ }
JSON Output (Structured for Log Aggregators)
use tracing_subscriber::fmt::format::Json;
tracing_subscriber::fmt()
.json()
.with_current_span(true)
.with_span_list(false)
.flatten_event(true)
.with_max_level(Level::INFO)
.init();
Output:
{"timestamp":"2026-05-04T10:00:00.123Z","level":"INFO","fields":{"message":"user authenticated","user_id":42},"target":"bhodl::auth","span":{"name":"process_request","request_id":"abc"}}
Pipe to log aggregator (Loki, Elasticsearch, Datadog).
Multiple Layers Composition
use tracing_subscriber::{fmt, EnvFilter, prelude::*, Registry};
let stdout_log = fmt::layer().with_target(true);
let json_log = fmt::layer().json().with_writer(std::io::stderr);
let file_appender = tracing_appender::rolling::daily("logs", "bhodl.log");
let (file_writer, _guard) = tracing_appender::non_blocking(file_appender);
let file_log = fmt::layer().json().with_writer(file_wr
Установить rust-tracing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditFAQ
Что делает скилл rust-tracing?
Rust `tracing` crate — structured, async-aware diagnostics. Spans, events, fields, instrument macro, subscribers (fmt, JSON, OpenTelemetry, Tokio Console), filtering (env-filter, RUST_LOG), targets, contextual fields with span data, integration with `tracing-subscriber` layers, OpenTelemetry export, and patterns for embedded/mobile (FFI to Android Logcat / iOS os.Logger), wallet apps with privacy-respecting log redaction. USE WHEN: user mentions "tracing", "tracing-subscriber", "instrument", "Span", "info!/error!/debug!", "tracing-opentelemetry", "tokio-console", "env-filter", "RUST_LOG", "JSON logs Rust", "structured logging Rust" DO NOT USE FOR: Mobile-specific log integration only - use `mobile/android-native` or `mobile/ios-native` DO NOT USE FOR: Java/Kotlin logging (slf4j) - use Java/Kotlin specific DO NOT USE FOR: Generic Rust language - use `languages/rust`
Как установить скилл rust-tracing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл rust-tracing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic