Prometheus — Dependencies#

Module info#

  • Module: github.com/prometheus/prometheus
  • Go version: 1.25.0
  • Direct dependencies: 103 (first require block in go.mod, no // indirect marker)
  • Indirect dependencies (explicitly listed): ~148 (second and third require blocks)
  • go.sum entries: 837 lines (~418 unique module/version pairs, capturing the full transitive graph)

Dependency categories#

Core infrastructure#

PackagePurpose
github.com/alecthomas/kingpin/v2CLI flag/argument parsing (replaces flag stdlib); drives the prometheus binary’s command-line interface
github.com/alecthomas/unitsHuman-friendly byte/duration unit parsing for config flags
github.com/fsnotify/fsnotifyOS-level filesystem events, used for hot-reloading of config files
github.com/oklog/runActor-model runner for composing concurrent long-lived goroutines at startup
go.uber.org/automaxprocsAuto-sets GOMAXPROCS to match the container CPU quota (critical for correct scheduling in Kubernetes pods)
github.com/KimMachineGun/automemlimitSets GOMEMLIMIT from cgroup memory limits; mirrors automaxprocs for memory
go.yaml.in/yaml/v2, v3, v4YAML parsing used for all Prometheus configuration files
github.com/grafana/regexpDrop-in replacement for regexp with RE2 semantics and better performance; the //nolint:depguard comment in main.go explains that the stdlib package is still needed for client_golang interop

Networking / HTTP / RPC#

PackagePurpose
google.golang.org/grpcgRPC transport; used for remote write/read and OTLP receiver
google.golang.org/protobuf + github.com/gogo/protobufProtobuf encoding/decoding; dual presence due to historical migration from gogo to the canonical google.golang.org package
github.com/mwitkow/go-conntrackHTTP connection tracking and labelling for metrics-aware http.Transport
github.com/munnerz/goautonegHTTP content negotiation (Accept header parsing) for the /metrics endpoint
github.com/miekg/dnsPure-Go DNS resolver; used by DNS-based service discovery
github.com/gorilla/websocket (indirect)WebSocket support via the Docker SDK dependency chain
github.com/julienschmidt/httprouter (indirect)Fast HTTP router pulled in as a transitive dep from prometheus/alertmanager

Data / Serialization / Storage#

PackagePurpose
github.com/cespare/xxhash/v2Fast 64-bit non-cryptographic hash; used heavily for label set fingerprinting in TSDB
github.com/dennwc/varintVariable-length integer encoding for the TSDB WAL and chunk format
github.com/edsrzf/mmap-goMemory-mapped files for TSDB block reads on all platforms
github.com/golang/snappySnappy compression for remote write payloads and TSDB chunks
github.com/klauspost/compressBroader compression support (zstd, gzip) used in remote write and chunk encoding
github.com/oklog/ulid/v2Monotonic, sortable IDs used to name TSDB block directories
github.com/bboreham/go-loserLoser-tree merge for multi-block label set iteration in TSDB queries
github.com/json-iterator/goFast JSON encoder/decoder; used in high-throughput API and alertmanager notification paths
github.com/gogo/protobufLegacy proto encoding still present for Remote Write v1 protocol compatibility
go.uber.org/atomicType-safe atomic wrappers (supplements sync/atomic); used in TSDB head
github.com/Code-Hex/go-generics-cacheGeneric LRU/TTL cache; used for service-discovery result caching

OpenTelemetry (OTLP bridge)#

PackagePurpose
go.opentelemetry.io/otel (+ metric, trace, sdk)OTel SDK; Prometheus exposes traces for its own operations
go.opentelemetry.io/otel/exporters/otlp/otlptrace/*OTLP trace exporters (gRPC and HTTP) for distributed tracing
go.opentelemetry.io/collector/component, consumer, pdata, processorOTel Collector component model; Prometheus acts as a collector pipeline node for OTLP ingestion
github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessorConverts OTel delta metrics to Prometheus-native cumulative form
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttpHTTP middleware injecting OTel spans
github.com/prometheus/otlptranslatorTranslates OTLP metric names/types to Prometheus model

Cloud provider SDKs (service discovery)#

ProviderPackages
AWSaws-sdk-go-v2 core + ec2, ecs, elasticache, kafka, lightsail, rds, sts, imds
Azureazure-sdk-for-go/sdk/azcore, azidentity, armcompute/v5, armnetwork/v4
GCPgoogle.golang.org/api, cloud.google.com/go/auth (indirect)
DigitalOceangithub.com/digitalocean/godo
Hetznergithub.com/hetznercloud/hcloud-go/v2
Linodegithub.com/linode/linodego
Vultrgithub.com/vultr/govultr/v3
Scalewaygithub.com/scaleway/scaleway-sdk-go
IONOSgithub.com/ionos-cloud/sdk-go/v6
Outscalegithub.com/outscale/osc-sdk-go/v2
OVHgithub.com/ovh/go-ovh
OpenStackgithub.com/gophercloud/gophercloud/v2
StackITgithub.com/stackitcloud/stackit-sdk-go/core

These are the most striking part of Prometheus’s dependency graph: every major cloud is a first-class direct dependency because each service discovery provider gets its own SDK.

HashiCorp ecosystem#

PackagePurpose
github.com/hashicorp/consul/apiConsul service discovery
github.com/hashicorp/nomad/apiNomad service discovery
github.com/hashicorp/go-retryablehttp (indirect)Retrying HTTP client pulled in by Consul/Nomad SDKs

Observability (self-instrumentation)#

PackagePurpose
github.com/prometheus/client_golangPrometheus uses its own client library to instrument itself — a clear dogfooding signal
github.com/prometheus/client_golang/expExperimental client features (new Remote API)
github.com/prometheus/client_modelShared protobuf types for the Prometheus exposition format
github.com/prometheus/commonShared utilities: promslog, promhttp, model types
github.com/prometheus/alertmanagerAlertmanager API types and client, for sending alerts
github.com/prometheus/exporter-toolkitTLS and web config for the web server
github.com/prometheus/sigv4AWS SigV4 signing for authenticated remote write to AWS endpoints
github.com/felixge/fgprofFull goroutine profiler (flame-graph style) exposed on /debug/fgprof
github.com/google/pprofpprof profile format support

Other infrastructure / Kubernetes#

PackagePurpose
k8s.io/client-go, k8s.io/api, k8s.io/apimachineryKubernetes service discovery (the most complex SD backend)
k8s.io/klog/v2Kubernetes logging framework; pulled in transitively by client-go
github.com/docker/dockerDocker service discovery and Docker daemon API
github.com/go-zookeeper/zkZookeeper service discovery (Nerve/Serverset)
github.com/kolo/xmlrpcXML-RPC client for Puppet-based service discovery (Puppet DB)
github.com/envoyproxy/go-control-plane/envoyxDS service discovery (Envoy control plane)
github.com/envoyproxy/protoc-gen-validateProtobuf validation used by the xDS integration
golang.org/x/oauth2OAuth2 flows for GCP, GitHub, and generic OAuth2 SD backends

Testing#

PackagePurpose
github.com/stretchr/testifyStandard assertion library (assert, require)
github.com/nsf/jsondiffJSON diff output for assertion messages
github.com/google/go-cmpDeep equality comparison, especially useful for proto structs
go.uber.org/goleakGoroutine leak detection in tests
github.com/pb33f/libopenapi + libopenapi-validatorOpenAPI spec parsing and validation; used to test the Prometheus HTTP API spec compliance

OpenAPI validation (unusual choice)#

pb33f/libopenapi and pb33f/libopenapi-validator are used to validate that the live Prometheus API responses conform to the bundled OpenAPI spec. This is a sophisticated approach to API contract testing and brings in a significant transitive dependency tree of its own (go-openapi/*, JSON Schema, etc.).

Stdlib reliance#

Prometheus’s core packages are stdlib-heavy. Key stdlib usage observed in cmd/prometheus/main.go and tsdb/head.go:

  • context — pervasive cancellation and deadline propagation
  • net/http — HTTP server for the web UI, API, and /metrics endpoint
  • sync (Mutex, RWMutex, WaitGroup, Once) — extensive use in TSDB and scrape manager
  • encoding/json — used at API layer
  • log/slog — the project migrated to log/slog (Go 1.21+) for structured logging, though prometheus/common/promslog wraps it
  • math, math/bits — TSDB integer arithmetic and chunk encoding
  • regexp — still directly imported in some places where grafana/regexp isn’t applicable
  • os, runtime, syscall — OS integration for signal handling, resource limits, mmap

The TSDB and PromQL engine layers are particularly stdlib-dependent: the parser, AST, and query evaluation loop use only Go builtins and internal packages, keeping that critical path dependency-free.

Shared dependencies#

Dependencies shared with other projects in the research set that create natural comparison points:

DependencyAlso used by
github.com/hashicorp/consul/apiConsul (the server), Vault, Nomad
github.com/hashicorp/nomad/apiNomad
k8s.io/client-goKubernetes itself (source), many cloud-native tools
google.golang.org/grpcetcd, Kubernetes, most CNCF projects
google.golang.org/protobufetcd, Kubernetes
github.com/stretchr/testifyVirtually universal across all 50 projects
go.opentelemetry.io/otelIncreasingly adopted by all CNCF-adjacent projects
github.com/docker/dockerProjects with container-aware SD or tooling
golang.org/x/oauth2Cloud-facing projects (Terraform, Vault, etc.)

Vendoring#

No vendor/ directory present. Prometheus relies entirely on the Go module proxy and go.sum for dependency integrity. This is the standard modern approach for a project of this scale, though it means reproducible builds depend on module proxy availability (or a local GOMODCACHE).

The go.mod contains two exclude directives:

  • github.com/linode/linodego v1.0.0 — excluded because that version was removed from GitHub
  • github.com/grpc-ecosystem/grpc-gateway v1.14.7 and google.golang.org/api v0.30.0 — excluded due to breaking changes (issue #7621)

And two replace directives:

  • Pins cloud.google.com/go to v0.123.0
  • Pins github.com/go-openapi/testify/v2 to v2.0.2 to preserve YAML assertion support

Notable dependency decisions#

  1. Every cloud = a direct dep. Rather than abstracting cloud SDKs behind an internal HTTP layer, each service discovery provider imports its vendor SDK directly. This maximises fidelity (auth, pagination, regional endpoints) but means adding a new SD provider requires evaluating a new SDK’s entire transitive dependency tree. The build-tag plugin architecture partially mitigates this by allowing users to build a binary with only the SD providers they need.

  2. grafana/regexp over stdlib regexp. Prometheus replaced regexp with a Grafana-maintained fork that offers significantly better performance for the workloads PromQL generates (many label-matching regexes against large label sets). The //nolint:depguard comment at the import site documents exactly where the stdlib package is still required — a clean engineering decision that leaves a breadcrumb for future maintainers.

  3. Dual protobuf stacks (gogo + google). The presence of both github.com/gogo/protobuf and google.golang.org/protobuf reflects a long-running migration. Remote Write v1 was designed around gogo for performance (zero-copy, arena allocation); Remote Write v2 uses the canonical library. Prometheus deliberately maintains both to avoid breaking the installed base of receivers.

  4. OpenTelemetry as a first-class integration layer. The OTel dependency is not just for self-instrumentation; Prometheus implements full OTel Collector component interfaces (component, consumer, processor) so it can act as a node in an OTel pipeline. This is a strategic architectural choice that positions Prometheus as a citizen of the OTel ecosystem rather than a competing silo.

  5. Minimal abstraction over stdlib HTTP. Prometheus does not use any third-party HTTP router framework (no Gin, Echo, Chi, Gorilla Mux). Routes are registered directly on http.ServeMux or via julienschmidt/httprouter (which comes in transitively). This keeps the web layer thin and dependency-light.

  6. go.yaml.in instead of gopkg.in/yaml. The project has migrated to the go.yaml.in fork (v2, v3, v4 all present simultaneously), which is the CNCF-governed continuation of the widely-used gopkg.in/yaml.v3. Having all three versions at once is a transient compatibility state, but shows forward motion toward the new fork.