Skip to content

transport-metrics

Comprehensive, cardinality-safe Prometheus instrumentation for Go services.

Expose a scrapeable Prometheus /metrics endpoint — pre-wired with Go runtime, process, and build-info collectors — from a single Register call, with zero external infrastructure. Watch heap, goroutines, GC and uptime; catch leaks with go tool pprof.

mux := http.NewServeMux()
// mount your API handlers…
_ = metrics.Register(mux, metrics.WithMiddleware(authMiddleware))

Prometheus, complementing OTel

This is the pull/scrape (Prometheus) counterpart to the push (OTel) go/observability modules. It complements them — use Prometheus for local, single-binary tools and classic scrape stacks; OTel when you have an OTLP pipeline; both if you like. See Pull vs push.

Highlights

  • Zero infra. Scrape or curl /metrics locally — no collector required.
  • Runtime out of the box. Go + process + build_info collectors on a private registry by default.
  • Guarded posture. Pass your auth middleware, or bind to loopback — never an open port. Mounting unguarded logs a warning.
  • Lean core, opt-in weight. Core is prometheus/client_golang + stdlib only; go/transport (standalone server), gRPC and OTel live in opt-in subpackages.

Where next


Part of the phpboyscout Go toolkit.