Skip to main content
A complete walkthrough of instrumenting a Go service using the official client_golang library. See the overview for the general approach.

1. Add the dependency

2. Register custom metrics and expose /metrics

The default registry automatically exports Go runtime metrics (go_* — goroutines, GC pauses, heap, etc.) and process metrics (process_* — CPU, memory, open FDs).
If your service already serves HTTP on another port, you can mount promhttp.Handler() on your existing mux at /metrics instead of starting a separate listener. Just point ops.json’s port at your main app port.

3. Declare the metrics endpoint in ops.json

4. Visualize with a community dashboard

To import: in Grafana, go to Dashboards → New → Import, enter the dashboard ID, and select your LocalOps Prometheus data source. You’ll instantly see goroutine counts, GC pause times, heap allocations, and CPU usage. Your custom application metrics (emails_sent_total, etc.) can be charted alongside.