promtest

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package promtest provides test utilites for testing Prometheus metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrometheusMetricTest

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

PrometheusMetricTest stores information about a metric to use for testing.

func NewPrometheusMetricTest

func NewPrometheusMetricTest(tb testing.TB, name string, metric prometheus.Collector, labels prometheus.Labels) *PrometheusMetricTest

NewPrometheusMetricTest creates a new test object for a Prometheus metric. It stores the current value of the metric along with the metric name.

func (*PrometheusMetricTest) CheckDelta

func (p *PrometheusMetricTest) CheckDelta(delta float64)

CheckDelta checks that the metric value changes exactly delta from when Helper was called.

func (*PrometheusMetricTest) CheckExists

func (p *PrometheusMetricTest) CheckExists()

CheckExists confirms that the metric exists and returns exactly 1 metrics.

It's a shorthand for CheckExistsN(1)

func (*PrometheusMetricTest) CheckExistsN added in v0.9.3

func (p *PrometheusMetricTest) CheckExistsN(count int)

CheckExistsN confirms that the metric exists and returns the count of metrics.

Please note that due to the limitation of upstream API, neither CheckExistsN nor CheckExists will limit the counts to the specified labels, so they will check against the number of metrics reported with all label values.

func (*PrometheusMetricTest) CheckSampleCountDelta added in v0.9.7

func (p *PrometheusMetricTest) CheckSampleCountDelta(delta int)

CheckSampleCountDelta checks that the number of samples (of histogram) is the exactly delta from when Helper was called.

Jump to

Keyboard shortcuts

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