client_golang

The official Prometheus instrumentation library for Go applications.

Library
Go
vv1.24.1
6,035 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
92 /100 Excellent
Development Activity 100
Maintenance 84
Community 84
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
85 /100 Excellent
Architecture 88
Code Quality 90
Innovation 82
Learning Curve 78

client_golang is the official Go client library for Prometheus, providing the core primitives (Counter, Gauge, Histogram, Summary) used to instrument application code, plus a registry for collecting and exposing those metrics. It also ships an HTTP client for querying the Prometheus HTTP API and a Pushgateway push client for batch jobs.

Maintained directly under the prometheus GitHub organization, it is the reference implementation most other language clients follow conceptually, and is the default choice for any Go service that needs to expose /metrics for Prometheus scraping.

What You Get

  • Core metric types — Counter, Gauge, Histogram, Summary — plus their …Vec variants for labeled metrics
  • A Registry/Registerer/Gatherer abstraction for collecting metrics from custom Collector implementations
  • promhttp.Handler() to expose a standard /metrics endpoint in Prometheus text or OpenMetrics exposition format
  • promauto constructors that register metrics automatically at construction time, removing boilerplate MustRegister calls
  • Built-in collectors for Go runtime stats (goroutines, GC, memstats) and process stats (CPU, memory, file descriptors)
  • A push package for sending metrics to a Prometheus Pushgateway from batch/cron jobs
  • testutil helpers (CollectAndCompare, ToFloat64, GatherAndCompare) for asserting on metric values in unit tests

Common Use Cases

  • Exposing a /metrics endpoint on a Go web service or API for Prometheus to scrape
  • Instrumenting request counts, latencies, and error rates with labeled CounterVec/HistogramVec metrics
  • Reporting custom application-level gauges (queue depth, active connections, cache hit ratio)
  • Pushing metrics from short-lived batch jobs or cron tasks via the Pushgateway client
  • Writing unit tests that assert specific metric values were recorded after an operation

Under The Hood

Architecture — The core of the library is prometheus/registry.go, which implements a Registry type satisfying both the Registerer interface (for registering Collectors) and the Gatherer interface (for scraping all registered collectors into a slice of dto.MetricFamily protobuf messages via internal goroutine-fed channels, capMetricChan/capDescChan). Individual metric types (counter.go, gauge.go, histogram.go — the latter alone is over 2,000 lines, covering both classic fixed-bucket histograms and native/sparse exponential histograms) implement the Metric and Collector interfaces so they can be registered directly or embedded inside custom collectors. promhttp/http.go wraps a Gatherer in an http.Handler that negotiates between Prometheus text format and OpenMetrics via content negotiation, applying gzip and error-handling options. promauto/auto.go is a thin factory layer over the same constructors that registers on creation and panics on failure, trading explicitness for reduced boilerplate. Sub-packages (collectors, push, testutil, api/prometheus) are independently importable so consumers only pull in what they use.

Tech Stack — Pure Go (99.3% of the codebase per GitHub’s language breakdown), targeting the two most recent major Go releases per its documented support policy (currently requiring Go 1.25 per go.mod). Dependencies are minimal and deliberately scoped: github.com/prometheus/client_model and google.golang.org/protobuf for the wire format, github.com/prometheus/common for shared exposition-format helpers, github.com/cespare/xxhash/v2 for fast label hashing, github.com/beorn7/perks for streaming quantile estimation in Summaries, and github.com/klauspost/compress for response compression in promhttp. No code generation frameworks or external build tooling beyond a standard Makefile.

Code Quality — Extensive test coverage: 69 _test.go files against 162 total .go files (roughly 43% of files are tests), including dedicated example tests (example_*_test.go) that double as executable documentation, a lint.go/promlint sub-package that validates metric naming conventions, and testutil.go exposing CollectAndCompare/GatherAndCompare specifically so downstream consumers can unit-test their own instrumentation. The .golangci.yml config enforces a strict lint baseline across the module. Error handling is explicit throughout — registration failures return errors (or panic only in the promauto/Must* variants, which is a documented, opt-in tradeoff) rather than failing silently.

API Design — The public API is built around small, composable interfaces (Collector, Registerer, Gatherer, Metric) which is idiomatic Go but does require understanding the collector/registry split before writing anything nontrivial — this is the library’s main source of onboarding friction. promauto exists specifically to shortcut that with import-and-call constructors for the common case. Naming is highly consistent (NewCounter/NewCounterVec/NewGauge/NewGaugeVec follow one predictable pattern), and the package-level doc.go includes a complete runnable example. The separation of instrumentation (prometheus), exposition (promhttp), auto-registration (promauto), and testing (testutil) into distinct importable sub-packages keeps each consumer’s dependency footprint minimal.

Used by 71 apps in this directory

Rust
65%
Apache 2.0

agentgateway

AI Development · Developer Tools · Mcp

5,071

An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.

View details
88
Repo Health
82
Technical
69
Dependency
Built with
Rust 65%
Go 23%
Updated 5 days ago
Go
85%
Apache 2.0

Argo Workflows

Data Engineering · Devops

17,006

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
68
Dependency
Built with
Go 85%
TypeScript 11%
Updated 4 days ago
Go
83%
Apache 2.0

Authelia

Authentication · Security

29,110

OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.

View details
91
Repo Health
81
Technical
75
Dependency
Built with
Go 83%
TypeScript 15%
Updated 5 days ago
Python
55%
Other

authentik

Authentication · Security

25,758

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
Python 55%
TypeScript 36%
Updated 4 days ago
Go
55%
Apache 2.0

Authgear

Authentication

2,074

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Go 55%
HTML 24%
TypeScript 18%
Updated 1 weeks ago
Go
84%
AGPL 3.0

Beta9

AI Development · Automation · Data Engineering

1,794

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
66
Dependency
Built with
Go 84%
Python 15%
Updated 5 days ago
Go
49%
MIT

Bytebase

Devops

14,512

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
92
Repo Health
73
Technical
68
Dependency
Built with
Go 49%
TypeScript 42%
Updated 4 days ago
Go
98%
Apache 2.0

Caddy

Devops · Security

76,128

The only web server that obtains and renews TLS certificates automatically, with HTTP/1-2-3 support and zero dependency on external runtimes.

View details
92
Repo Health
86
Technical
75
Dependency
Built with
Go 98%
Updated 6 days ago
Go
75%
AGPL 3.0

Coder

Code Editors · Developer Tools · Devops

16,729

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
91
Repo Health
90
Technical
65
Dependency
Built with
Go 75%
TypeScript 23%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers