go-observability
Skill72 starsChanged 4 months agoMITView on GitHub
Structured logging, distributed tracing, metrics, and health checks for Go services. Covers slog, OpenTelemetry, Prometheus, and observability best practices. Use when: "add logging", "structured logs", "add tracing", "OpenTelemetry", "add metrics", "Prometheus", "observability", "instrument this code". Not for: pprof profiling (go-performance-review), error handling (go-error-handling), health endpoints (go-api-design).
2 other projects use a version of this.
Adopted by
Most recently taken up by
- Dankosik/golang-backend-skillstheir own version, first seen Sep 8, 2026
- muratmirgun/gopherstheir own version, first seen Aug 11, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- muratmirgun/gophers★ 9same name
- Dankosik/golang-backend-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository36 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/go-skills.mdcCursor rule
- go-api-designSkill
- go-architecture-reviewSkill
- go-cliSkill
- go-dependency-injectionSkill
- go-design-patternsSkill
- go-graphqlSkill
- go-grpcSkill
- go-interface-designSkill
- go-openapiSkill
- go-project-layoutSkill
- go-code-reviewSkill
- go-coding-standardsSkill
- go-contextSkill
- go-data-structuresSkill
- go-documentationSkill
- go-error-handlingSkill
- go-modernizeSkill
- go-databaseSkill
- go-concurrency-reviewSkill
- go-defensive-codingSkill
- go-performance-reviewSkill
- go-security-auditSkill
- go-troubleshootingSkill
- go-test-qualitySkill
- go-test-table-drivenSkill
- git-commitSkill
- go-binary-sizeSkill
- go-ciSkill
- go-dependency-auditSkill
- go-refactoringSkill
- go-semantic-toolsSkill
- go-skills-routerSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 4 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Read a reference file only when the section below is not enough.
- Very specific: line 36
Use log/slog (Go 1.21+) with a JSON handler in production.
- Distinctive: line 60
NEVER log at Error level for expected conditions (user not found → Info or Warn).
- Very specific: line 78
Start a span for every operation worth seeing on a waterfall — inbound requests, DB calls, outbound HTTP, meaningful business steps — and …
- Very specific: line 111
Keep cardinality bounded. Label with the route pattern, method and status — never a user ID, request ID or raw r.URL.Path, each of which …
- Very specific: line 133
All logging uses log/slog with structured key-value pairs, not fmt.Printf or log.Printf
- Distinctive: line 135
No sensitive data (passwords, tokens, PII) in log output
- Distinctive: line 140
No high-cardinality labels (user IDs, request IDs) in metrics
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Observability
Observability is not optional for production services. Every service must produce
structured logs, expose metrics, and propagate trace context. Use the stdlib
log/slog for logging and OpenTelemetry for tracing and metrics.
Detailed reference material, loaded on demand:
references/slog.md— handler setup, logger injection, child loggers.references/tracing.md— tracer provider, spans, propagation, shutdown.references/metrics.md— metric definitions, HTTP instrumentation.
Read a reference file only when the section below is not enough.
1. Structured Logging with slog
Use log/slog (Go 1.21+) with a JSON handler in production. Every line is
key-value pairs, never a formatted sentence:
// ✅ Good — structured, leveled
logger.Info("user created", slog.String("user_id", user.ID), slog.Duration("latency", elapsed))
// ❌ Bad — unparseable in production
log.Printf("user %s created in %v", user.ID, elapsed)Inject the logger as a dependency; never reach for a package-level global.
Derive child loggers with logger.With(...) so component, method and request
ID are attached once instead of at every call site. See references/slog.md.
Log levels — use them consistently
| Level | Use for |
Debug | Verbose diagnostic info, disabled in production |
Info | Normal operations: request received, job completed |
Warn | Recoverable issues: retry succeeded, deprecated usage |
Error | Failures requiring attention: DB down, external call failed |
NEVER log at Error level for expected conditions (user not found → Info or Warn).
Sensitive data — NEVER log
- Passwords, tokens, API keys
- Full credit card numbers, SSNs
- Raw request bodies containing PII
// ✅ Good — redacted
logger.Info("auth attempt", slog.String("user", email), slog.Bool("success", ok))
// ❌ Bad — leaks credentials
logger.Info("auth attempt", slog.String("password", password))2. Distributed Tracing with OpenTelemetry
Start a span for every operation worth seeing on a waterfall — inbound
requests, DB calls, outbound HTTP, meaningful business steps — and always
defer span.End().
Rules the reference examples follow:
- Name the span after the operation (
GetUser,db.query), never after the fully-qualified function, and neverdoStuff. - On failure call
span.RecordError(err)andspan.SetStatus(codes.Error, ...), or the trace shows a green span for a failed request. - Pass
ctxdown the whole chain. Acontext.Background()mid-chain silently starts a new trace and breaks the parent link.
Setup and examples in references/tracing.md.
3. Metrics with OpenTelemetry / Prometheus
| Type | Use for | Example |
| Counter | Monotonically increasing values | Requests total, errors total |
| Gauge | Values that go up and down | Active connections, queue depth |
| Histogram | Distribution of values | Request latency, response size |
Naming is <namespace>_<subsystem>_<name>_<unit>:
http_request_duration_seconds ✅ (unit in name)
http_requests_total ✅ (counter with _total suffix)
db_connections_active ✅ (gauge, no suffix needed)
user_signups ❌ (missing _total for counter)
requestLatency ❌ (camelCase, no unit)Keep cardinality bounded. Label with the route pattern, method and status —
never a user ID, request ID or raw r.URL.Path, each of which mints a new
time series per value and eventually takes the metrics backend down.
Definitions and middleware in references/metrics.md.
4. Connecting Logs, Traces, and Metrics
A log line without a trace ID cannot be joined to the request that produced
it. Pull trace.SpanContextFromContext(ctx) and attach trace_id and
span_id to the logger at the top of each handler or service method.
5. Graceful Shutdown of Telemetry
The batch span processor holds spans in memory. Call tp.Shutdown(ctx) with
its own timeout on the way out, or the last seconds before a crash — the
interesting ones — never reach the collector.
Both examples in references/tracing.md.
Verification Checklist
- All logging uses
log/slogwith structured key-value pairs, notfmt.Printforlog.Printf - Logger is injected as a dependency, not used as a global
- No sensitive data (passwords, tokens, PII) in log output
- Trace context is propagated through all function calls via
context.Context - Spans are created for significant operations (DB calls, HTTP requests, business logic)
- Spans record errors with
span.RecordError(err)and set error status - Metrics follow naming conventions:
_seconds,_total,_bytes - No high-cardinality labels (user IDs, request IDs) in metrics
- Telemetry providers are shut down gracefully on service exit
- Trace IDs are included in log entries for correlation
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

