headgate-prometheus crate and Go headgateprometheus module translate the
worker’s exporter-neutral telemetry events into the same native Prometheus collectors.
They do not start a server, use the default global registry, or scrape the Headgate store.
Your application owns the registry, HTTP endpoint, and access to that endpoint.
Install
Attach it to a worker
Use a dedicated application registry and construct one Headgate adapter for it. If one process runs multiple workers, share that adapter throughArc in Rust or its pointer in
Go rather than registering the same metric names again.
Rust
Pass the adapter throughWorkerConfig::telemetry. The same registry is later gathered
by the application’s HTTP handler.
Content-Type from TextEncoder::format_type() in the selected HTTP
framework. Headgate deliberately does not choose or start that framework.
Go
WorkerConfig.telemetry or Go headgate.Config.Telemetry,
which means it observes worker execution. A producer-only client does not run jobs and has
no worker metrics to emit.
Exported metrics
headgate_jobs_rejected_total currently covers the handler-declared rate-limit path.
The admission gate evaluates queue pause, fairness, quarantine, and fleet concurrency
inside the store and does not return rejected candidates merely to feed a counter.
Useful PromQL
Jobs completed per second by kind:Cardinality and privacy
The adapter labels metrics only with queue, kind, policy, outcome, and worker identity. It deliberately excludes job IDs, fingerprints, partition or tenant keys, payloads, headers, results, errors, and logs. Adding those values as labels creates an unbounded time-series count and can turn normal queue traffic into a Prometheus incident.Registration behavior
Rustheadgate_prometheus::Telemetry::new requires an explicit &prometheus::Registry;
Go headgateprometheus.New requires an explicit prometheus.Registerer. Calling either
twice with the same registry returns a duplicate-registration error instead of reusing
unknown collectors or panicking. If registration fails partway through, collectors added
by that call are removed before the error is returned.
If an application deliberately needs a prefix or constant labels, wrap its registry with
Prometheus’s registerer helpers before passing it to New. Keep constant labels bounded
to deployment metadata such as service or cluster; never use a job or tenant identifier.
OpenTelemetry
Export traces and metrics through application-owned OpenTelemetry providers.