var MetricNameLabel … var QuantileLabel … type Metrics … // Equal returns true if all metrics are the same as the arguments. func (m *Metrics) Equal(o Metrics) bool { … } // NewMetrics returns new metrics which are initialized. func NewMetrics() Metrics { … } // ParseMetrics parses Metrics from data returned from prometheus endpoint func ParseMetrics(data string, output *Metrics) error { … } // 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. func TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error) { … } // PrintSample returns formatted representation of metric Sample func PrintSample(sample *model.Sample) string { … } // ComputeHistogramDelta computes the change in histogram metric for a selected label. // Results are stored in after samples func ComputeHistogramDelta(before, after model.Samples, label model.LabelName) { … } func makeKey(a, b model.LabelValue) string { … } // GetMetricValuesForLabel returns value of metric for a given dimension func GetMetricValuesForLabel(ms Metrics, metricName, label string) map[string]int64 { … } // ValidateMetrics verifies if every sample of metric has all expected labels func ValidateMetrics(metrics Metrics, metricName string, expectedLabels ...string) error { … } type Histogram … type HistogramVec … // GetAggregatedSampleCount aggregates the sample count of each inner Histogram. func (vec HistogramVec) GetAggregatedSampleCount() uint64 { … } // GetAggregatedSampleSum aggregates the sample sum of each inner Histogram. func (vec HistogramVec) GetAggregatedSampleSum() float64 { … } // Quantile first aggregates inner buckets of each Histogram, and then // computes q-th quantile of a cumulative histogram. func (vec HistogramVec) Quantile(q float64) float64 { … } // Average computes wrapped histograms' average value. func (vec HistogramVec) Average() float64 { … } // Validate makes sure the wrapped histograms have all necessary fields set and with valid values. func (vec HistogramVec) Validate() error { … } // GetHistogramVecFromGatherer collects a metric, that matches the input labelValue map, // 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 GetHistogramVecFromGatherer(gatherer metrics.Gatherer, metricName string, lvMap map[string]string) (HistogramVec, error) { … } func uint64Ptr(u uint64) *uint64 { … } type bucket … func bucketQuantile(q float64, buckets []bucket) float64 { … } // Quantile computes q-th quantile of a cumulative histogram. // It's expected the histogram is valid (by calling Validate) func (hist *Histogram) Quantile(q float64) float64 { … } // Average computes histogram's average value func (hist *Histogram) Average() float64 { … } // Validate makes sure the wrapped histogram has all necessary fields set and with valid values. func (hist *Histogram) Validate() error { … } // GetGaugeMetricValue extracts metric value from GaugeMetric func GetGaugeMetricValue(m metrics.GaugeMetric) (float64, error) { … } // GetCounterMetricValue extracts metric value from CounterMetric func GetCounterMetricValue(m metrics.CounterMetric) (float64, error) { … } // GetHistogramMetricValue extracts sum of all samples from ObserverMetric func GetHistogramMetricValue(m metrics.ObserverMetric) (float64, error) { … } // GetHistogramMetricCount extracts count of all samples from ObserverMetric func GetHistogramMetricCount(m metrics.ObserverMetric) (uint64, error) { … } // LabelsMatch returns true if metric has all expected labels otherwise false func LabelsMatch(metric *dto.Metric, labelFilter map[string]string) bool { … } // GetCounterVecFromGatherer collects a counter that matches the given name // from a gatherer implementing k8s.io/component-base/metrics.Gatherer interface. // It returns all counter values that had a label with a certain name in a map // that uses the label value as keys. // // Used only for testing purposes where we need to gather metrics directly from a running binary (without metrics endpoint). func GetCounterValuesFromGatherer(gatherer metrics.Gatherer, metricName string, lvMap map[string]string, labelName string) (map[string]float64, error) { … } func findMetricFamily(metricFamilies []*dto.MetricFamily, metricName string) *dto.MetricFamily { … }