Agent skill
telemetry
Telemetry and observability conventions. Apply when adding tracing, logging, metrics, or instrumentation to Rust code.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/telemetry
SKILL.md
Telemetry & Observability Conventions
If the project has a dedicated telemetry/observability spec or conventions document, read it first — it takes precedence over the generic guidance below.
Log Levels
| Level | When to Use | Example |
|---|---|---|
error! |
Unrecoverable failures requiring operator attention | External service call failed permanently |
warn! |
Recoverable issues, degraded operation | Retry triggered, fallback activated |
info! |
Lifecycle events, operational milestones | Server started, connection established |
debug! |
Internal state useful during development | State machine transition details |
trace! |
Per-frame, hot-path data (high volume) | Frame encoded, bytes serialized |
Instrumentation Depth
Not all code deserves the same instrumentation level. Choose based on the crate's role:
- Hot-path code (serialization, framing, tight loops):
trace!only, no spans. Spans add overhead that matters here. - Type definition crates (pure data types, no logic):
trace!only if anything at all. - Core business logic (servers, handlers, state machines): Full instrumentation —
#[instrument]+ spans. - Client-facing code (SDKs, CLI flows): Full instrumentation for debuggability.
#[instrument] Rules
- Use on async functions that represent logical operations or flow steps
- Skip on hot-path synchronous functions (serialization, encoding, tight loops)
- Always
skipsensitive fields: tokens, keys, passwords, raw payloads - Include identifying fields that aid correlation (IDs, resource names)
- Set appropriate
level— default isINFO, uselevel = "debug"orlevel = "trace"for noisy functions
Structured Logging
Always use named fields, never string interpolation:
// Good: named fields — searchable, parseable
trace!(payload_bytes = payload.len(), frame_bytes = buf.len(), "frame encoded");
// Bad: string interpolation — opaque to log aggregators
trace!("frame encoded, payload={}, frame={}", payload.len(), buf.len());
Span Design
For request/message processing pipelines, use a three-tier span pattern:
- Inbound span: one per received message/request (message type, size, sender ID)
- Process span: business logic processing (operation type, affected resources)
- Outbound span: one per response/forwarded message (recipient, payload size)
This gives visibility into where time is spent and enables per-hop latency analysis.
General Principles
- Prefer
tracingoverlog— structured spans enable distributed tracing - Log at the point of decision, not at every intermediate step
- Include enough context to diagnose without reproducing: IDs, sizes, error details
- Never log secrets, tokens, keys, or raw user data — even at
trace!level - Use
Displayfor user-facing context,Debugfor developer diagnostics
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?