fix: add buckets_set function to interface

main
Jef Roosens 2023-01-28 17:32:57 +01:00
parent bf1385ee6d
commit ae2eeeb974
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 4 additions and 1 deletions

View File

@ -23,6 +23,7 @@ pub interface MetricsCollector {
mut: mut:
counter_set(val u64, metric Metric) counter_set(val u64, metric Metric)
counter_increment(metric Metric) counter_increment(metric Metric)
histogram_buckets_set(name string, buckets []f64)
histogram_record(value f64, metric Metric) histogram_record(value f64, metric Metric)
gauge_set(value f64, metric Metric) gauge_set(value f64, metric Metric)
gauge_add(value f64, metric Metric) gauge_add(value f64, metric Metric)

2
null.v
View File

@ -19,6 +19,8 @@ pub fn (c &NullCollector) counters() []Metric {
return [] return []
} }
pub fn (mut c DefaultCollector) histogram_buckets_set(name string, buckets []f64) {}
pub fn (c &NullCollector) histogram_record(value f64, metric Metric) {} pub fn (c &NullCollector) histogram_record(value f64, metric Metric) {}
pub fn (c &NullCollector) histogram_get(metric Metric) ?Histogram { pub fn (c &NullCollector) histogram_get(metric Metric) ?Histogram {

View File

@ -40,7 +40,7 @@ fn test_only_gauges() {
fn test_single_histogram() { fn test_single_histogram() {
mut m := new_default_collector() mut m := new_default_collector()
m.histogram_buckets_set('test', [0.5, 5.0]) m.histogram_buckets_set('test', [0.5, 5.0])
m.histogram_record(5.0, name: 'test') m.histogram_record(5.0, name: 'test')
m.histogram_record(7.0, name: 'test') m.histogram_record(7.0, name: 'test')