testmetrics

package
v0.0.0-...-0da26dc Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testmetrics gets information from metrics for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Retriever

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

Retriever retrieves prometheus metrics and provides an API to get metric values. The 'initial' snapshot is taken when the Retriever is created and the 'final' snapshot is taken when the first metric is obtained.

func NewRetrieverFromGatherer

func NewRetrieverFromGatherer(t *testing.T) *Retriever

NewRetrieverFromGatherer creates a new metrics retriever that retrieves metrics from the in memory default prometheus gatherer.

func (*Retriever) GetCounterValues

func (ma *Retriever) GetCounterValues(t *testing.T, metricName string, labels map[string]string) (float64, float64)

GetCounterValues returns the values for both the "initial" and "final" time of a counter type metric. If the metric is not a counter, this method fails. If the metric does not exist, this method returns 0s.

func (*Retriever) GetHistogramBuckets

func (ma *Retriever) GetHistogramBuckets(t *testing.T, metricName string, labels map[string]string) ([]*pb.Bucket, []*pb.Bucket)

GetHistogramBuckets returns the buckets for both the "initial" and "final" time of a histogram type metric. If the metric is not a histogram, this method fails. If the metric does not exist, this method returns empty buckets.

func (*Retriever) IncrementBucketsCumulatively

func (ma *Retriever) IncrementBucketsCumulatively(buckets []*pb.Bucket, value float64, incrementStep int) []*pb.Bucket

IncrementBucketsCumulatively increments the given buckets according to the provided value and increment step. Note that incrementing a bucket will increment all the higher buckets as it is a cumulative counter per bucket.

Jump to

Keyboard shortcuts

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