metricstest

package
v2.0.0-...-2f3a09e Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package metricstest provides test helpers for asserting that components correctly register and update Prometheus metrics.

Use New to obtain an isolated metrics.Metrics instance backed by a fresh prometheus.Registry. Call Gather to retrieve the current metric families and assert on their values without involving the process-global default registry.

Warning: this package is intended for use in tests only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gather

func Gather(tb testing.TB, m *metrics.Metrics) map[string]*dto.MetricFamily

Gather collects all metric families from m and returns them keyed by fully- qualified metric name. The test fails immediately if gathering returns an error.

func New

func New(tb testing.TB) *metrics.Metrics

New returns an isolated metrics.Metrics instance backed by a fresh registry. The component is NOT started: Go runtime and process collectors are not registered, keeping gathered output minimal and deterministic.

Pass the returned metrics.Metrics to the component under test, then call Gather to inspect the resulting metric families.

Types

This section is empty.

Jump to

Keyboard shortcuts

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