Documentation
¶
Overview ¶
Package metrics provides utilities for parsing and validating telemetry metrics in e2e tests.
Index ¶
- type HistogramData
- type PrometheusMetric
- type PrometheusMetrics
- func (m PrometheusMetrics) FindByName(name string) PrometheusMetrics
- func (m PrometheusMetrics) FindByNamePrefix(prefix string) PrometheusMetrics
- func (m PrometheusMetrics) GetHistogram(name string, labels map[string]string) (*HistogramData, bool)
- func (m PrometheusMetrics) GetValue(name string) (float64, bool)
- func (m PrometheusMetrics) GetValueWithLabels(name string, labels map[string]string) (float64, bool)
- func (m PrometheusMetrics) HasMetric(name string) bool
- func (m PrometheusMetrics) Names() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HistogramData ¶
type HistogramData struct {
SampleCount uint64
SampleSum float64
// BucketCount is the number of emitted `le` buckets (including `+Inf`). A
// value greater than one proves the distribution survived the exposition
// format, as opposed to an exponential histogram collapsed to `+Inf` only.
BucketCount int
}
HistogramData holds the aggregated values of a Prometheus histogram metric.
type PrometheusMetric ¶
type PrometheusMetric struct {
Name string
Labels map[string]string
Value float64
// Histogram holds the aggregated histogram data when the metric is a
// histogram; it is nil for every other metric type.
Histogram *HistogramData
}
PrometheusMetric represents a parsed Prometheus metric.
type PrometheusMetrics ¶
type PrometheusMetrics []PrometheusMetric
PrometheusMetrics is a collection of parsed Prometheus metrics.
func ParsePrometheusMetrics ¶
func ParsePrometheusMetrics(r io.Reader) (PrometheusMetrics, error)
ParsePrometheusMetrics parses Prometheus exposition format text into structured metrics.
func (PrometheusMetrics) FindByName ¶
func (m PrometheusMetrics) FindByName(name string) PrometheusMetrics
FindByName returns all metrics with the given name.
func (PrometheusMetrics) FindByNamePrefix ¶
func (m PrometheusMetrics) FindByNamePrefix(prefix string) PrometheusMetrics
FindByNamePrefix returns all metrics whose name starts with the given prefix.
func (PrometheusMetrics) GetHistogram ¶
func (m PrometheusMetrics) GetHistogram( name string, labels map[string]string, ) (*HistogramData, bool)
GetHistogram returns the histogram data for the metric matching name and all specified labels. Returns nil and false if not found or not a histogram.
func (PrometheusMetrics) GetValue ¶
func (m PrometheusMetrics) GetValue(name string) (float64, bool)
GetValue returns the value of the first metric with the given name. Returns 0 and false if not found.
func (PrometheusMetrics) GetValueWithLabels ¶
func (m PrometheusMetrics) GetValueWithLabels(name string, labels map[string]string) (float64, bool)
GetValueWithLabels returns the value of the metric matching name and all specified labels. Returns 0 and false if not found.
func (PrometheusMetrics) HasMetric ¶
func (m PrometheusMetrics) HasMetric(name string) bool
HasMetric returns true if a metric with the given name exists.
func (PrometheusMetrics) Names ¶
func (m PrometheusMetrics) Names() []string
Names returns all unique metric names.