Documentation ¶
Index ¶
- Variables
- func CollectAndCompare(c metrics.Collector, expected io.Reader, metricNames ...string) error
- func ComputeHistogramDelta(before, after model.Samples, label model.LabelName)
- func CustomCollectAndCompare(c metrics.StableCollector, expected io.Reader, metricNames ...string) error
- func ExtractMetricSamples(metricsBlob string) ([]*model.Sample, error)
- func GatherAndCompare(g metrics.Gatherer, expected io.Reader, metricNames ...string) error
- func GetCounterMetricValue(m metrics.CounterMetric) (float64, error)
- func GetGaugeMetricValue(m metrics.GaugeMetric) (float64, error)
- func GetHistogramMetricValue(m metrics.ObserverMetric) (float64, error)
- func GetMetricValuesForLabel(ms Metrics, metricName, label string) map[string]int64
- func NewFakeKubeRegistry(ver string) metrics.KubeRegistry
- func ParseMetrics(data string, output *Metrics) error
- func PrintSample(sample *model.Sample) string
- func ValidateMetrics(metrics Metrics, metricName string, expectedLabels ...string) error
- type Histogram
- type Metrics
Constants ¶
This section is empty.
Variables ¶
var ( // MetricNameLabel is label under which model.Sample stores metric name MetricNameLabel model.LabelName = model.MetricNameLabel // QuantileLabel is label under which model.Sample stores latency quantile value QuantileLabel model.LabelName = model.QuantileLabel )
Functions ¶
func CollectAndCompare ¶
CollectAndCompare registers the provided Collector with a newly created pedantic Registry. It then does the same as GatherAndCompare, gathering the metrics from the pedantic Registry.
func ComputeHistogramDelta ¶
ComputeHistogramDelta computes the change in histogram metric for a selected label. Results are stored in after samples
func CustomCollectAndCompare ¶
func CustomCollectAndCompare(c metrics.StableCollector, expected io.Reader, metricNames ...string) error
CustomCollectAndCompare registers the provided StableCollector with a newly created registry. It then does the same as GatherAndCompare, gathering the metrics from the pedantic Registry.
func ExtractMetricSamples ¶
ExtractMetricSamples parses the prometheus metric samples from the input string.
func GatherAndCompare ¶
GatherAndCompare gathers all metrics from the provided Gatherer and compares it to an expected output read from the provided Reader in the Prometheus text exposition format. If any metricNames are provided, only metrics with those names are compared.
func GetCounterMetricValue ¶ added in v0.18.0
func GetCounterMetricValue(m metrics.CounterMetric) (float64, error)
GetCounterMetricValue extract metric value from CounterMetric
func GetGaugeMetricValue ¶ added in v0.18.0
func GetGaugeMetricValue(m metrics.GaugeMetric) (float64, error)
GetGaugeMetricValue extract metric value from GaugeMetric
func GetHistogramMetricValue ¶ added in v0.18.0
func GetHistogramMetricValue(m metrics.ObserverMetric) (float64, error)
GetHistogramMetricValue extract sum of all samples from ObserverMetric
func GetMetricValuesForLabel ¶ added in v0.18.0
GetMetricValuesForLabel returns value of metric for a given dimension
func NewFakeKubeRegistry ¶ added in v0.18.0
func NewFakeKubeRegistry(ver string) metrics.KubeRegistry
NewFakeKubeRegistry creates a fake `KubeRegistry` that takes the input version as `build in version`. It should only be used in testing scenario especially for the deprecated metrics. The input version format should be `major.minor.patch`, e.g. '1.18.0'.
func ParseMetrics ¶
ParseMetrics parses Metrics from data returned from prometheus endpoint
func PrintSample ¶
PrintSample returns formated representation of metric Sample
Types ¶
type Histogram ¶ added in v0.18.0
Histogram wraps prometheus histogram DTO (data transfer object)
func GetHistogramFromGatherer ¶ added in v0.18.0
GetHistogramFromGatherer collects a metric from a gatherer implementing k8s.io/component-base/metrics.Gatherer interface. Used only for testing purposes where we need to gather metrics directly from a running binary (without metrics endpoint).
func (*Histogram) Clear ¶ added in v0.18.0
func (hist *Histogram) Clear()
Clear clears all fields of the wrapped histogram