Documentation ¶
Overview ¶
Package helpers provides test helpers for Prometheus exporters.
It contains workarounds for the following issues:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectMetrics ¶ added in v0.7.0
func CollectMetrics(collector Collector) []prometheus.Metric
CollectMetrics receives all metrics from collector.
func Format ¶
func Format(metrics []prometheus.Metric) []string
Format converts a slice of Prometheus metrics to strings in text exposition format.
func Parse ¶ added in v0.7.0
func Parse(metrics []string) []prometheus.Metric
Parse converts strings in text exposition format to a slice of Prometheus metrics.
func WriteMetric ¶ added in v0.7.0
func WriteMetric(metric *Metric) prometheus.Metric
WriteMetric creates Prometheus metric.
func WriteMetrics ¶ added in v0.7.0
func WriteMetrics(metrics []*Metric) []prometheus.Metric
WriteMetrics creates Prometheus metrics.
Types ¶
type Collector ¶ added in v0.7.0
type Collector interface {
Collect(ch chan<- prometheus.Metric)
}
Collector is a subset of prometheus.Collector with a single method.
type Metric ¶
type Metric struct { Name string Help string Labels prometheus.Labels Type dto.MetricType Value float64 }
Metric contains Prometheus metric details.
func ReadMetric ¶
func ReadMetric(metric prometheus.Metric) *Metric
ReadMetric extracts details from Prometheus metric.
func ReadMetrics ¶ added in v0.7.0
func ReadMetrics(metrics []prometheus.Metric) []*Metric
ReadMetrics extracts details from Prometheus metrics.
func (*Metric) Less ¶ added in v0.7.0
Less returns true if m < m2 in some stable order. Can be used for sorting.
func (*Metric) Metric ¶ added in v0.7.0
func (m *Metric) Metric() prometheus.Metric
Metric returns Prometheus metric with same information.