structured-logging

Emit structured logs with OpenTelemetry conventions and correlate them with distributed traces.

Updated Sep 9, 2026
One-click install
npx skills add https://github.com/DeepSpaceCartel/skills --skill structured-logging-deepspacecartel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: structured-logging
Source: https://github.com/DeepSpaceCartel/skills/tree/main/skills/structured-logging
Command: npx skills add https://github.com/DeepSpaceCartel/skills --skill structured-logging-deepspacecartel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Free-text log messages cannot be filtered, aggregated, or correlated across services, making debugging slow and causing backend outages from high-cardinality labels and leaked secrets. This Skill provides the OpenTelemetry log data model and semantic conventions needed to emit queryable, trace-correlated structured logs. ## Core Features & Use Cases - Log Data Model Guidance: Apply the OTel record model (Timestamp, SeverityText/Number, Body, Attributes, Resource, EventName, TraceId/SpanId) with stable dotted event names instead of prose messages. - Semantic Conventions: Use standard attribute names for HTTP (http.request.method, http.route, url.path), errors (error.type, exception.*), and resources (service.name, service.version, deployment.environment.name). - Trace Correlation & Cardinality Control: Inject W3C trace context into every log record, keep backend labels low-cardinality (Loki), and redact secrets at the logger level. - Use Case: When reviewing a service's logging, replace an access log that dumps raw URLs with a structured http.request.completed event carrying route, status, duration, and trace ids. ## Quick Start Review the logging in this service and rewrite it as structured OpenTelemetry-style events with trace correlation and low-cardinality labels.

Frequently Asked Questions about structured-logging

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

FAQPage Schema
How do I structure application logs with OpenTelemetry?▼

Emit records with named, typed fields following the OTel log data model: Timestamp, SeverityText, Body, Attributes, Resource, and EventName. Use stable dotted event names like image.build.completed instead of interpolated message strings, and set resource attributes once per logger.

How do I correlate logs with distributed traces?▼

Inject the W3C trace context (trace_id and span_id) into every log record, which most OTel logging instrumentations do automatically when logging inside an active span. Pick one key convention (trace_id/span_id or trace.id/span.id) and keep it consistent across the fleet.

What labels are safe to use in Loki?▼

Loki labels must be low-cardinality: service, environment, cluster, and level are safe defaults. Never use request IDs, user IDs, URLs, or timestamps as labels, since unbounded distinct values cause stream explosion and outages; keep those in log attributes instead.

Should I log the raw request URL in access logs?▼

No. Log the route template (http.route) and path (url.path) separately instead of the raw URL with its query string. Raw URLs create high-cardinality values and can leak tokens or keys carried in query parameters.

How do I prevent secrets from appearing in logs?▼

Configure redaction at the logger level for authorization headers, API keys, tokens, cookies, and password fields rather than relying on developer discipline. Prefer structured fields over dumping whole objects like request.headers or process.env, since denylists always miss something.

What is the difference between a trace ID and a request ID?▼

A trace ID identifies one distributed trace across many services and is generated by the tracing SDK, while a request ID identifies one inbound request to one service and is generated at the edge. Keep both in separate fields; the request ID is the fallback correlation key for untraced services.