alex123098/my-dotfiles/go-observability
Claude Code and agent skill by alex123098/my-dotfiles
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Go production observability — structured logging with slog, Prometheus metrics, OpenTelemetry tracing, pprof profiling. Use when instrumenting Go services for production monitoring, adding metrics or tracing, or debugging production issues.
Install
npx vskill@latest install alex123098/my-dotfiles/go-observabilitySKILL.md
Procedure
- Structured Logging (slog): Use
log/slog(Go 1.21+) — neverfmt.Printlnorlog.Printfin production. Set up JSON handler:slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, nil))). Always use context variants:slog.InfoContext(ctx, "msg", "key", val)to correlate with traces. Use log levels: Debug=dev, Info=normal operations, Warn=degraded state, Error=failure needing attention. Replacezap/logrus/zerologwith slog — use bridge handlers during migration (e.g., samber/slog-zap). - Prometheus Metrics: Four metric types: Counter (rate of events, always increases), Gauge (snapshot values, can go up/down), Histogram (latency, size distributions — PREFER over Summary), Summary (quantiles, can't aggregate across instances). Always label with bounded values — NEVER unbounded (user IDs, full URLs). Write PromQL queries as comments above metric declarations for discoverability. Use
prometheus.DefBucketsfor HTTP latency histograms. - OpenTelemetry Tracing: Set up TracerProvider at service startup. Add spans to every meaningful operation: service methods, DB queries, external API calls. Use
otelhttpmiddleware for automatic HTTP instrumentation. Record errors withspan.RecordError(). Propagate context viapropagatorsfor cross-service trace continuity. Correlate with logs usingotelslogbridge (trace_id, span_id injected automatically). - pprof Profiling: Enable pprof endpoints (with authentication) for on-demand profiling: CPU, heap, goroutine, mutex, block profiles. Toggle via env vars. Capture with
curl /debug/pprof/profile?seconds=30 > cpu.pprof. Analyze withgo tool pprof -http=:8080 cpu.pprof. For continuous profiling, use Pyroscope. - Signal Correlation & Alerting: Embed trace_id in logs for jumping from log line to full trace. Attach exemplars on histogram metrics linking latency spikes to exact traces. A feature is NOT done until observable: metrics declared, proper logging in place, spans created. Set up alerts on four golden signals: latency, traffic, errors, saturation.
Pitfalls
- Logging AND returning the same error — violates single handling rule, creates duplicate logs.
- High-cardinality metric labels (user IDs, emails, full URLs) — destroys Prometheus performance.
- Using Summary instead of Histogram for latency — can't aggregate across instances.
- Not passing context to slog calls — breaks trace correlation between logs and traces.
- Exposing pprof endpoints without authentication in production — information disclosure risk.
- Using
irateinstead ofratein PromQL alerting rules — causes flapping alerts.
Verification
- All production logging uses
slog— grep forfmt.Println,log.Printshows zero results. - Every exported function returns a
slog-logged error or wrapped error — never both. - Each HTTP endpoint has latency histogram + error counter metrics declared.
go tool pprofcan connect to /debug/pprof/ endpoints.- All slog calls use
Contextvariants for trace correlation.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpi/.pi/agent/skills/go-observability/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/alex123098/my-dotfiles/go-observability)