mirror of
https://github.com/hanzoai/ingress.git
synced 2026-10-20 15:07:40 +00:00
metrics: one way for a subsystem to publish a collector
Register adds a collector to the registry the metrics endpoint already serves. The alternative is a method on the Registry interface and an implementation of it in every backend, for a number one subsystem raises.
This commit is contained in:
@@ -78,6 +78,19 @@ func PrometheusHandler() http.Handler {
|
||||
return promhttp.HandlerFor(promRegistry, promhttp.HandlerOpts{})
|
||||
}
|
||||
|
||||
// Register adds a collector to the registry this endpoint serves.
|
||||
//
|
||||
// It is how a subsystem publishes a counter of its own — the alternative is a
|
||||
// method on the Registry interface and an implementation of it in every
|
||||
// backend, for a number only one subsystem raises. Registering the same
|
||||
// collector twice is not an error; the first registration stands.
|
||||
func Register(c stdprometheus.Collector) {
|
||||
var already stdprometheus.AlreadyRegisteredError
|
||||
if err := promRegistry.Register(c); err != nil && !errors.As(err, &already) {
|
||||
log.Error().Err(err).Msg("Unable to register metric")
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterPrometheus registers all Prometheus metrics.
|
||||
// It must be called only once and failing to register the metrics will lead to a panic.
|
||||
func RegisterPrometheus(ctx context.Context, config *otypes.Prometheus) Registry {
|
||||
|
||||
Reference in New Issue
Block a user