metrics

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package metrics owns the Prometheus registry shared across Gantry subsystems and provides constructor helpers that record metric ownership so final audit can verify the metric set is complete.

Subsystems do NOT call prometheus.MustRegister directly; they go through (*Registry).NewCounter / NewGauge / NewHistogram so the ownership map is populated automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameOwner

type NameOwner struct {
	Name      string
	Subsystem string
}

NameOwner is one row of the ownership audit.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry wraps a *prometheus.Registry with an ownership map of metric name -> subsystem.

func New

func New() *Registry

New returns a Registry with an empty Prometheus registry. New does not install any default Go/process collectors so tests don't see runtime metric noise; cmd/gantry wires those collectors explicitly via reg.RegisterDefaultCollectors.

func (*Registry) Handler

func (r *Registry) Handler() http.Handler

Handler returns an http.Handler serving /metrics.

func (*Registry) NewCounter

func (r *Registry) NewCounter(subsystem string, opts prometheus.CounterOpts) prometheus.Counter

NewCounter registers a Counter and records its ownership.

func (*Registry) NewCounterVec

func (r *Registry) NewCounterVec(subsystem string, opts prometheus.CounterOpts, labels []string) *prometheus.CounterVec

NewCounterVec registers a CounterVec and records its ownership.

func (*Registry) NewGauge

func (r *Registry) NewGauge(subsystem string, opts prometheus.GaugeOpts) prometheus.Gauge

NewGauge registers a Gauge and records its ownership.

func (*Registry) NewGaugeFunc

func (r *Registry) NewGaugeFunc(subsystem string, opts prometheus.GaugeOpts, f func() float64) prometheus.GaugeFunc

NewGaugeFunc registers a GaugeFunc and records its ownership.

func (*Registry) NewGaugeVec

func (r *Registry) NewGaugeVec(subsystem string, opts prometheus.GaugeOpts, labels []string) *prometheus.GaugeVec

NewGaugeVec registers a GaugeVec and records its ownership.

func (*Registry) NewHistogram

func (r *Registry) NewHistogram(subsystem string, opts prometheus.HistogramOpts) prometheus.Histogram

NewHistogram registers a Histogram and records its ownership.

func (*Registry) NewHistogramVec

func (r *Registry) NewHistogramVec(subsystem string, opts prometheus.HistogramOpts, labels []string) *prometheus.HistogramVec

NewHistogramVec registers a HistogramVec and records its ownership.

func (*Registry) Owners

func (r *Registry) Owners() []NameOwner

Owners returns the metric-name -> subsystem map, sorted by name. Used by audit step to compare against the inventory.

func (*Registry) PrometheusRegistry

func (r *Registry) PrometheusRegistry() *prometheus.Registry

PrometheusRegistry exposes the underlying *prometheus.Registry for tests or for code that must register a third-party collector directly.

func (*Registry) RegisterDefaultCollectors

func (r *Registry) RegisterDefaultCollectors()

RegisterDefaultCollectors adds the standard process and Go runtime collectors. Call from cmd/gantry, not from tests.

Jump to

Keyboard shortcuts

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