Skip to main content
The Rust 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 through Arc in Rust or its pointer in Go rather than registering the same metric names again.

Rust

Pass the adapter through WorkerConfig::telemetry. The same registry is later gathered by the application’s HTTP handler.
Set the response Content-Type from TextEncoder::format_type() in the selected HTTP framework. Headgate deliberately does not choose or start that framework.

Go

The adapter belongs on Rust 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.
Do not expose /metrics directly to the public internet. Bind it to an internal listener or protect it with the same network and authentication controls used for other operational endpoints.

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:
P99 attempt time by queue and kind:
Fleet utilization:
Quarantine activity worth paging or investigating:
Memory-guard restart activity:
For backlog age, arrival rate, drain rate, and time-to-drain, use the bounded control API queue statistics. Those values are store-wide aggregates; this process-local adapter cannot derive them truthfully from one runner.

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

Rust headgate_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.