feat: add NullCollector
parent
ab065681aa
commit
7f6327b01a
10
collector.v
10
collector.v
|
@ -44,7 +44,7 @@ pub fn (mut c DefaultCollector) counter_register(value u64, metric Metric) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut c DefaultCollector) counter_increment(metric Metric) {
|
||||
pub fn (c &DefaultCollector) counter_increment(metric Metric) {
|
||||
rlock c.counters {
|
||||
entry := c.counter_indexes[metric.str()]
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub fn (mut c DefaultCollector) counter_increment(metric Metric) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut c DefaultCollector) counter_decrement(metric Metric) {
|
||||
pub fn (c &DefaultCollector) counter_decrement(metric Metric) {
|
||||
rlock c.counters {
|
||||
entry := c.counter_indexes[metric.str()]
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub fn (mut c DefaultCollector) counter_decrement(metric Metric) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut c DefaultCollector) counter_get(metric Metric) ?u64 {
|
||||
pub fn (c &DefaultCollector) counter_get(metric Metric) ?u64 {
|
||||
return rlock c.counters {
|
||||
entry := c.counter_indexes[metric.str()] or { return none }
|
||||
|
||||
|
@ -77,7 +77,7 @@ pub fn (mut c DefaultCollector) histogram_register(metric Metric) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut c DefaultCollector) histogram_add(value f64, metric Metric) {
|
||||
pub fn (c &DefaultCollector) histogram_add(value f64, metric Metric) {
|
||||
entry := rlock c.histograms {
|
||||
c.histograms[metric.str()]
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ pub fn (mut c DefaultCollector) histogram_add(value f64, metric Metric) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn (mut c DefaultCollector) histogram_get(metric Metric) ?[]f64 {
|
||||
pub fn (c &DefaultCollector) histogram_get(metric Metric) ?[]f64 {
|
||||
entry := rlock c.histograms {
|
||||
c.histograms[metric.str()] or { return none }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
module metrics
|
||||
|
||||
[heap]
|
||||
struct NullCollector {}
|
||||
|
||||
pub fn new_null_collector() &NullCollector {
|
||||
return &NullCollector{}
|
||||
}
|
||||
|
||||
pub fn (c &NullCollector) counter_register(value u64, metric Metric) {}
|
||||
|
||||
pub fn (c &NullCollector) counter_increment(metric Metric) {}
|
||||
|
||||
pub fn (c &NullCollector) counter_decrement(metric Metric) {}
|
||||
|
||||
pub fn (c &NullCollector) counter_get(metric Metric) ?u64 {
|
||||
return none
|
||||
}
|
||||
|
||||
pub fn (c &NullCollector) histogram_register(metric Metric) {}
|
||||
|
||||
pub fn (c &NullCollector) histogram_add(value f64, metric Metric) {}
|
||||
|
||||
pub fn (c &NullCollector) histogram_get(metric Metric) ?[]f64 {
|
||||
return none
|
||||
}
|
Loading…
Reference in New Issue