golang-observability

Instrument Go services with structured logging, Prometheus metrics, OpenTelemetry traces, and profiling.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-observability-jylhis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-observability
Source: https://github.com/Jylhis/claude-marketplace/tree/main/plugins/golang-dev/skills/golang-observability
Command: npx skills add https://github.com/Jylhis/claude-marketplace --skill golang-observability-jylhis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a complete, opinionated playbook to make Go services observable in production by adding structured logging, reliable Prometheus metrics, OpenTelemetry tracing, continuous profiling, RUM event tracking, alerting, and dashboards so teams can detect, diagnose, and resolve issues quickly.

Core Features & Use Cases

  • Structured logging: migrate legacy loggers to log/slog, emit JSON logs, and attach trace context via *Context variants so logs correlate with traces.
  • Metrics & alerting: prefer histograms for latency, keep label cardinality low, include PromQL comments above metric declarations, and use awesome-prometheus-alerts for dependency rules.
  • Tracing & correlation: set up OpenTelemetry TracerProvider, create spans for service methods/DB/external calls, record errors with RecordError + SetStatus, and use exemplars to link metrics to traces.
  • Profiling & RUM: enable pprof securely and toggle continuous profiling (Pyroscope) via environment variables; use user_id (not email) for server-side RUM and respect consent checks.
  • Use case: instrument a new HTTP endpoint so it emits JSON logs with trace_id, exposes histogram latency metrics with low-cardinality labels, creates spans for DB calls, and wires alerts and Grafana panels.

Quick Start

Instrument my Go HTTP handler with slog JSON logging that uses Info level in production, add a Prometheus histogram for request duration with route-pattern labels, create OpenTelemetry spans for service and DB calls, and enable pprof/pyroscope toggles via PROFILING_ENABLED.

Frequently Asked Questions about golang-observability

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

FAQPage Schema
How do I instrument a Go HTTP service with OpenTelemetry traces and slog structured logging?

Instrument Go HTTP services by setting up an OpenTelemetry TracerProvider to create spans for service and DB calls, and migrate legacy loggers to log/slog to emit JSON logs with propagated trace context for correlation.

What is the best way to expose Prometheus latency metrics in Go without causing high cardinality?

The best way to expose Prometheus latency metrics is by using histograms for request duration with route-pattern labels, keeping label cardinality low, and including exemplars to link metrics directly to OpenTelemetry traces.

Can I securely enable pprof and continuous profiling in my Go microservices?

Yes, you can securely enable pprof by using environment variable toggles like PROFILING_ENABLED, allowing you to activate continuous profiling with Pyroscope safely in production without exposing endpoints by default.

How do I correlate Go application logs with OpenTelemetry traces?

Correlate Go application logs with traces by using log/slog Context variants to attach trace context, ensuring emitted JSON logs include the trace_id so they can be linked directly to OpenTelemetry spans.

Does this observability approach work for setting up Grafana dashboards and alerting rules?

Yes, this approach works for Grafana dashboards and alerting by emitting compatible Prometheus metrics and utilizing awesome-prometheus-alerts rules to configure alerts for service dependencies and latency thresholds.

When should I use histograms over counters for Prometheus metrics in Go APIs?

You should use histograms over counters when measuring latency distributions like request duration in Go APIs, allowing Prometheus to calculate percentiles while keeping label cardinality low for efficient querying.