prometheus

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package prometheus is the built-in Prometheus telemetry.MetricExporter driver — it exposes Harbor's metrics on a pull /metrics endpoint in the Prometheus text exposition format.

RFC §6.14 promotes a built-in Prometheus /metrics endpoint to V1 for self-hosted setups (a popular operator preference; resolves a Q-2). This driver is the default — telemetry.NewMetricsRegistry selects it when TelemetryConfig.OTelEndpoint is empty, because the Prometheus path needs no collector: the metrics are pulled by a Prometheus server scraping the /metrics handler.

Per-registry scrape registry — NOT the global default

The OTel Prometheus exporter defaults to registering with prometheus.DefaultRegisterer (process-global mutable state). This driver deliberately does NOT use that: each call to Reader builds a FRESH prometheus.Registry and registers the exporter's collector with it via WithRegisterer. That keeps every telemetry.MetricsRegistry independent — two registries in one process (a test running N of them; a future multi-listener setup) do not collide on the global registerer, and the concurrent-reuse contract holds. The fresh registry is handed back through the PromGatherer contract so telemetry.PrometheusHandler can build a promhttp handler from it.

The driver self-registers from init() under the name "prometheus"; pull it in via blank import at the binary entry point:

import _ "github.com/hurtener/Harbor/internal/telemetry/drivers/prometheus"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL