GO

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.zip

Installs 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.
329 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

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

You give it
Go source code, existing logging and telemetry configurations
You get back
Refactored Go code with structured logs, correlation fields, redaction policies, and updated tests

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

  1. Inspect current logger + telemetry setup.
  2. Define event schema before writing new events.
  3. Add correlation fields (trace_id, span_id, request_id) everywhere.
  4. Enforce redaction and field allowlists before adding business context.
  5. Add request summary events and targeted step/error events.
  6. Validate cardinality, payload size, and sampling policy.
  7. 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.Attr keys 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_id and span_id on 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 DEBUG for local/targeted diagnostics.
  • Use INFO for request summaries and business milestones.
  • Use WARN for degraded but recoverable conditions.
  • Use ERROR for 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.

SkillInstallsUpdatedSafetyDifficulty
go-logging-observability (this skill)04moNo flagsIntermediate
service-mesh-observability52moNo flagsAdvanced
opentelemetry-instrumentation-extension37moReviewAdvanced
logging21moNo flagsBeginner

Try saying

Example prompts that trigger this skill in your AI assistant.

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.

574

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.

326

logging

HoangNguyen0403

Standards for structured logging and observability in Golang.

210

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".

14

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,

13

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.

12

Search skills

Search the agent skills registry