structured-logging-and-tracing

structured-logging-and-tracing is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 101 tokens per session (1,439 once invoked), scanned A, original, Apache-2.0.

A guide to recording structured logs, measurements, and traces from a service. These are machine-readable records, numbers, and request paths that help show what happened across parts of a system.

In plain words
What is it for?
Use it when adding or changing logging, metrics, spans, or request correlation, while following the repository’s existing tools and conventions.
Why use it?
Unstructured or unsafe logs make production failures hard to investigate and may expose secrets or personal data. Consistent fields and correlation IDs make related events easier to follow.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding or changing logging, metrics, spans, or request correlation, while following the repository’s existing tools and conventions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/structured-logging-and-tracing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tmj-90/gaffer --skill structured-logging-and-tracing
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for structured-logging-and-tracing

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/structured-logging-and-tracing/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/structured-logging-and-tracing)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/structured-logging-and-tracing"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/structured-logging-and-tracing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for structured-logging-and-tracing

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/structured-logging-and-tracing"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/structured-logging-and-tracing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,439 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.01439
Opus 5.5 $0.00040 $0.00576
Sonnet 5.5 $0.00020 $0.00288
Haiku 4.5 $0.00010 $0.00144

Measured 16d ago against content hash e9580845826e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

structured-logging-and-tracing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/structured-logging-and-tracing/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Instrument code with structured logs, metrics and traces

Observability is designed where the code knows what happened. Emit events a machine can filter and a human can read, carry one trace context through every hop, measure the few things an alert needs, and never write a secret or a person's data into a log that lives for ninety days. Sources: W3C Trace Context (Recommendation); OpenTelemetry semantic conventions (HTTP spans and metrics, log data model); OWASP Logging Cheat Sheet; Google SRE book ch. 6 (four golden signals).

Steps

  1. Use the repo's instrumentation. Find the structured logger, metrics client, tracing SDK (OpenTelemetry if present) and the correlation convention. Call search_lore for standard field names (request_id, ticket, duration_ms). A second logger or tracer is a defect.
  2. Log events, not sentences. One record per meaningful event: stable event name plus typed fields, e.g. {"event":"claim.released","ticket":42,"reason":"ttl_expired"}, not "released ticket " + n. Units in field names (duration_ms, size_bytes). The logger's serialiser escapes values, which also stops log injection (CR/LF in user input forging lines); never build log lines by concatenation.
  3. Choose levels deliberately. error: a failure someone must act on. warn: degraded but handled. info: state transitions an operator follows. debug: the rest. A swallowed exception is logged with its error class and cause, never at debug only.
  4. Propagate trace context across every hop. Accept and emit W3C traceparent (00-<32 hex trace-id>-<16 hex span-id>-<flags>) and tracestate on HTTP; put the same fields in queue message headers and job payloads, and pass them to spawned processes (env or argument). Stamp trace_id and span_id on every log record in that unit of work (OTel log correlation). If the repo also has a request_id, carry both. Do not put secrets or personal data in baggage; it travels to third parties.
  5. Add spans at slow or flaky boundaries — inbound requests, outbound HTTP, DB queries, queue publish/consume, subprocesses — using the SDK's auto-instrumentation where it exists. Follow semantic conventions: HTTP span name {method} {route} (GET /tickets/{id}, never the raw URL with ids), attributes http.request.method, http.route, http.response.status_code, server.address, error.type. Status: server spans mark 5xx as Error and leave 4xx unset; client spans mark both 4xx and 5xx as Error. Record the exception on the span; never attach payloads.
  6. Measure what an alert would use. The golden signals for the operation: a duration histogram (OTel: http.server.request.duration, seconds), a counter of outcomes by result, and saturation gauges (queue depth, pool in-use). Metric labels are low-cardinality (route template, status class, kind); user ids, ticket numbers, URLs and error messages go on spans or logs, never labels. Alert design: the observability-designer skill.
  7. Log the security-relevant events (OWASP): authentication success and failure, authorisation denials, input-validation failures at trust boundaries, admin and permission changes, with who, what, when, from where and outcome.
  8. Redact by construction. Never log passwords, tokens, session ids, API keys, Authorization/Cookie headers, full request or response bodies, or personal data beyond need. Allow-list emitted fields or use the repo's redaction helper; hash an identifier if correlation is needed (the data-privacy skill).

Read the full file on GitHub · 94 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +30 lines e9580845826e
  2. 19d ago First seen · 64 lines · 101 tokens per session scan A af78e0eea290

Subscribe to this mod's changes

structured-logging-and-tracing is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 101 tokens to every session and 1,439 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.