Documentation ¶
Overview ¶
Package testmetrics gets information from metrics for testing.
Index ¶
- type Retriever
- func (ma *Retriever) GetCounterValues(t *testing.T, metricName string, labels map[string]string) (float64, float64)
- func (ma *Retriever) GetHistogramBuckets(t *testing.T, metricName string, labels map[string]string) ([]*pb.Bucket, []*pb.Bucket)
- func (ma *Retriever) IncrementBucketsCumulatively(buckets []*pb.Bucket, value float64, incrementStep int) []*pb.Bucket
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 ¶
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.