metrics/metrics.v

38 lines
800 B
Coq
Raw Normal View History

2022-12-26 13:31:50 +01:00
module metrics
2022-12-26 21:49:07 +01:00
import io
2022-12-26 13:31:50 +01:00
[params]
pub struct Metric {
pub:
2022-12-26 13:31:50 +01:00
name string [required]
labels [][2]string
}
pub fn (m &Metric) str() string {
return '$m.name $m.labels'
2022-12-26 13:31:50 +01:00
}
2022-12-26 15:03:57 +01:00
pub interface MetricsCollector {
counter_get(metric Metric) ?u64
2022-12-26 18:17:27 +01:00
counters() []Metric
histogram_get(metric Metric) ?[]f64
2022-12-26 21:49:07 +01:00
histograms() []Metric
2022-12-26 18:17:27 +01:00
gauge_get(metric Metric) ?f64
2022-12-26 21:49:07 +01:00
gauges() []Metric
2022-12-26 18:17:27 +01:00
mut:
counter_set(val u64, metric Metric)
counter_increment(metric Metric)
histogram_record(value f64, metric Metric)
gauge_set(value f64, metric Metric)
gauge_add(value f64, metric Metric)
gauge_sub(value f64, metric Metric)
2022-12-26 13:31:50 +01:00
}
2022-12-26 21:49:07 +01:00
pub interface MetricsExporter {
load(prefix string, collector MetricsCollector)
2022-12-26 21:49:07 +01:00
export_to_writer(writer io.Writer) !
export_to_string() !string
serialize_metric(metric Metric) string
2022-12-26 21:49:07 +01:00
}