go-logging-observability
Builds robust, correlated observability into Go services using structured logging and OpenTelemetry.
Install
mkdir -p .claude/skills/go-logging-observability && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13610" && unzip -o skill.zip -d .claude/skills/go-logging-observability && rm skill.zipInstalls to .claude/skills/go-logging-observability
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Build and review production-grade Go logging and observability with `log/slog` and OpenTelemetry. Use when adding or refactoring logs, instrumenting request paths, defining event schemas, reducing log cost/cardinality, enforcing redaction/PII policy, correlating logs with traces, or reviewing Go services for observability gaps.Key capabilities
- →Inspect current logger and telemetry setup
- →Define event schema before writing new events
- →Add correlation fields everywhere
- →Enforce redaction and field allowlists
- →Validate cardinality, payload size, and sampling policy
- →Add or update tests that assert log fields and redaction behavior
How it works
The skill guides the implementation of structured logging and observability in Go applications by defining event schemas, enforcing redaction, and correlating logs with traces.
Inputs & outputs
When to use go-logging-observability
- →Refactoring logs to structured format
- →Instrumenting request paths
- →Setting up OpenTelemetry
- →Enforcing logging redaction policies
About this skill
Go Logging Observability
Implement logging that is queryable, correlated, and safe by default.
Prefer structured slog events plus traces over free-form messages.
Workflow
- Inspect current logger + telemetry setup.
- Define event schema before writing new events.
- Add correlation fields (
trace_id,span_id,request_id) everywhere. - Enforce redaction and field allowlists before adding business context.
- Add request summary events and targeted step/error events.
- Validate cardinality, payload size, and sampling policy.
- Add or update tests that assert log fields and redaction behavior.
Core Rules
Use structured logs with log/slog
- Instantiate one shared base logger at process startup.
- Use
slog.Attrkeys from a stable schema. - Prefer typed values (
Int,Bool,Duration,Time) over string formatting. - Do not log raw JSON strings.
Correlate logs and traces
- Include
trace_idandspan_idon every request-scoped event. - Include stable request correlation (
request_id,operation,service,env). - Start spans at service boundaries and propagate context to downstream calls.
Enforce redaction and secrets policy
- Default to denylist + allowlist:
- Never log credentials, tokens, headers like
authorization, cookies, full payload bodies, or raw SQL with values. - Hash or truncate user identifiers where exact identity is not required.
- Log error classes/codes; sanitize error messages before emission.
Control cardinality and cost
- Keep high-cardinality fields limited to required correlation keys.
- Keep request summary events bounded in width.
- Use sampling/rate limiting for high-volume info events.
- Do not emit large nested objects; prefer compact, named subfields.
Use event taxonomy, not ad-hoc text
- Emit at least one request summary event per completed request.
- Emit step events only for meaningful state transitions or latency bottlenecks.
- Emit error events with category + retryability + boundary (client/dependency/internal).
- Keep event names stable (
http.request.completed,db.query.failed).
Preserve useful levels
- Use
DEBUGfor local/targeted diagnostics. - Use
INFOfor request summaries and business milestones. - Use
WARNfor degraded but recoverable conditions. - Use
ERRORfor failed operations requiring attention.
Go Implementation Pattern
func LogRequestComplete(ctx context.Context, logger *slog.Logger, reqID string, status int, dur time.Duration, err error) {
attrs := []slog.Attr{
slog.String("event", "http.request.completed"),
slog.String("request_id", reqID),
slog.Int("status_code", status),
slog.Duration("duration_ms", dur),
}
if span := trace.SpanContextFromContext(ctx); span.IsValid() {
attrs = append(attrs,
slog.String("trace_id", span.TraceID().String()),
slog.String("span_id", span.SpanID().String()),
)
}
if err != nil {
logger.ErrorContext(ctx, "request failed",
append(attrs, slog.String("error_class", classifyError(err)))...,
)
return
}
logger.InfoContext(ctx, "request completed", attrs...)
}
Review Checklist
- Verify new log fields match schema.md.
- Verify no PII/secrets exposure and redaction test coverage exists.
- Verify correlation fields exist on all request and dependency events.
- Verify cardinality budget and sampling decisions are documented.
- Verify event names and levels are consistent across services.
References
- Schema and naming rules:
references/schema.md - Rollout and migration checklist:
references/rollout-checklist.md - go-bubbletea event catalog:
references/go-bubbletea-event-catalog.md
Limitations
- →Logs must be structured with `log/slog`
- →Correlation fields like `trace_id` and `span_id` are required
- →Redaction and secrets policy must be enforced
How it compares
This skill provides a structured, policy-driven approach to Go logging and observability, contrasting with ad-hoc logging practices.
Compared to similar skills
go-logging-observability side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| go-logging-observability (this skill) | 0 | 4mo | No flags | Intermediate |
| service-mesh-observability | 5 | 2mo | No flags | Advanced |
| opentelemetry-instrumentation-extension | 3 | 7mo | Review | Advanced |
| logging | 2 | 1mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by riordanpawley
View all by riordanpawley →You might also like
service-mesh-observability
wshobson
Implement comprehensive observability for service meshes including distributed tracing, metrics, and visualization. Use when setting up mesh monitoring, debugging latency issues, or implementing SLOs for service communication.
opentelemetry-instrumentation-extension
docker
Extend OpenTelemetry instrumentation when new functionality is added to the MCP Gateway. Use when (1) new operations/functions are added, (2) reviewing code for missing instrumentation, (3) user requests otel/telemetry additions, or (4) working with state-changing operations. Analyzes git diff, suggests instrumentation points following project standards in docs/telemetry/README.md, implements with approval, writes tests, updates documentation, and verifies with debug logging and docker logs.
logging
HoangNguyen0403
Standards for structured logging and observability in Golang.
gcloud-usage
fcakyon
This skill should be used when user asks about "GCloud logs", "Cloud Logging queries", "Google Cloud metrics", "GCP observability", "trace analysis", or "debugging production issues on GCP".
error-diagnostics-error-trace
sickn33
You are an error tracking and observability expert specializing in implementing comprehensive error monitoring solutions. Set up error tracking systems, configure alerts, implement structured logging,
devops-troubleshooter
sickn33
Expert DevOps troubleshooter specializing in rapid incident response, advanced debugging, and modern observability. Masters log analysis, distributed tracing, Kubernetes debugging, performance optimization, and root cause analysis. Handles production outages, system reliability, and preventive monitoring. Use PROACTIVELY for debugging, incident response, or system troubleshooting.