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 )
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.
ComputeHistogramDelta computes the change in histogram metric for a selected label. Results are stored in after samples
CustomCollectAndCompare registers the provided StableCollector with a newly created registry. It then does the same as GatherAndCompare, gathering the metrics from the pedantic Registry.
ExtractMetricSamples parses the prometheus metric samples from the input string.
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.
GetCounterMetricValue extract metric value from CounterMetric
GetGaugeMetricValue extract metric value from GaugeMetric
GetHistogramMetricValue extract sum of all samples from ObserverMetric
GetMetricValuesForLabel returns value of metric for a given dimension
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'.
ParseMetrics parses Metrics from data returned from prometheus endpoint
PrintSample returns formated representation of metric Sample
TextToMetricFamilies reads 'in' as the simple and flat text-based exchange format and creates MetricFamily proto messages. It returns the MetricFamily proto messages in a map where the metric names are the keys, along with any error encountered.
ValidateMetrics verifies if every sample of metric has all expected labels
Histogram wraps prometheus histogram DTO (data transfer object)
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).
Average computes histogram's average value
Clear clears all fields of the wrapped histogram
Quantile computes q-th quantile of a cumulative histogram. It's expected the histogram is valid (by calling Validate)
Validate makes sure the wrapped histogram has all necessary fields set and with valid values.
Metrics is generic metrics for other specific metrics
NewMetrics returns new metrics which are initialized.
Equal returns true if all metrics are the same as the arguments.