Documentation
¶
Overview ¶
Package promhelp provides helper functions for asserting Prometheus metric values in unit tests.
Index ¶
- func Compare(reg prometheus.Gatherer, compare string, metricNames ...string) error
- func CounterValue(t testing.TB, reg prometheus.Gatherer, metricName string, ...) int
- func GaugeValue(t testing.TB, reg prometheus.Gatherer, metricName string, ...) int
- func HistogramValue(t testing.TB, reg prometheus.Gatherer, metricName string, ...) *io_prometheus_client.Histogram
- func MetricValue(t testing.TB, reg prometheus.Gatherer, metricName string, ...) *io_prometheus_client.Metric
- func RegistryDump(reg *prometheus.Registry) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare(reg prometheus.Gatherer, compare string, metricNames ...string) error
Compare can be used to compare a registry to some prometheus formatted text. If any values differ, an error is returned. If metric names are passed in, only those metrics will be compared. Usage: `Compare(reg, RegistryDump(reg))`
func CounterValue ¶
func CounterValue(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels) int
CounterValue returns the value of a counter metric with the given name and labels.
func GaugeValue ¶
func GaugeValue(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels) int
GaugeValue returns the value of a gauge metric with the given name and labels.
func HistogramValue ¶
func HistogramValue(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels) *io_prometheus_client.Histogram
HistogramValue returns the value of a histogram metric with the given name and labels.
func MetricValue ¶
func MetricValue(t testing.TB, reg prometheus.Gatherer, metricName string, labels prometheus.Labels) *io_prometheus_client.Metric
func RegistryDump ¶
func RegistryDump(reg *prometheus.Registry) string
RegistryDump returns the http page for a given registry's metrics. Very useful for visual debugging.
Types ¶
This section is empty.