go-observability

Instrument Go services with structured logs, Prometheus metrics, OpenTelemetry traces, profiles, and RUM.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-observability-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-observability
Source: https://github.com/asarchami/dotfiles/tree/main/dot_config/opencode/skills/go/go-observability
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-observability-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go services often ship without adequate observability, making production issues hard to diagnose and SLOs impossible to measure. This Skill provides a disciplined five-signal framework — logs, metrics, traces, profiles, and RUM — so every feature is observable before it ships. ## Core Features & Use Cases - Five-signal instrumentation: Guides structured logging with slog, Prometheus metrics with bounded cardinality, OpenTelemetry tracing, pprof/Pyroscope profiling, and GDPR-compliant RUM event tracking. - PR review and audit workflows: Provides checklists for reviewing instrumentation changes in pull requests and auditing observability coverage across an entire codebase with parallel per-signal checks. - Logger migration: Step-by-step migration path from zap, logrus, or zerolog to the standard library slog using bridge handlers. - Use Case: When adding a new HTTP endpoint to a Go service, use this Skill to declare latency and error-rate metrics with PromQL comments, create spans with error recording, emit structured context-aware logs, and wire alerts into Grafana. ## Quick Start Ask the AI to instrument your Go service's HTTP handlers with Prometheus metrics, slog structured logging, and OpenTelemetry tracing following the five-signals approach.

Frequently Asked Questions about go-observability

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

FAQPage Schema
How do I add Prometheus metrics to a Go service?

Use the Prometheus client_golang library to declare Counters for events, Gauges for current state, and Histograms for latency distributions, then expose them via promhttp.Handler on a /metrics endpoint. Keep label cardinality bounded and document each metric with PromQL queries and alert rules as comments above the declaration.

How to migrate from zap or logrus to slog in Go?

Migrate incrementally using bridge handlers like samber/slog-zap or samber/slog-logrus that route slog output through your existing logger. Replace call sites with slog.Info-style calls one by one, then remove the bridge and old dependency once migration is complete.

Should I use Histogram or Summary for latency metrics in Prometheus?

Prefer Histogram in almost all cases because its bucket counts are stored server-side and can be aggregated across instances using histogram_quantile(). Summary computes quantiles client-side that cannot be aggregated, making it suitable only for single-instance diagnostics.

Why should I avoid high-cardinality labels in Prometheus metrics?

Every unique label combination creates a separate time series, so unbounded values like user IDs or full URLs cause memory explosion and slow queries on the Prometheus server. Use route templates, status code buckets, and keep label values under roughly 100 unique values.

Can I enable pprof profiling in production Go services safely?

Yes, enable pprof via an environment variable toggle so it can be switched on without redeploying, but always protect the endpoints with authentication and network isolation. Exposed pprof endpoints leak sensitive runtime information and can be abused for denial of service.

How do I make RUM event tracking GDPR compliant in Go?

Check user consent before firing any server-side analytics events, use an immutable user_id rather than email as the identity key, and implement data export and deletion endpoints that propagate to your analytics platform and CDP. Self-hosting tools like PostHog simplifies cross-border data transfer compliance.