aboutsummaryrefslogtreecommitdiffstats
path: root/metrics/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'metrics/metrics.go')
-rw-r--r--metrics/metrics.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/metrics/metrics.go b/metrics/metrics.go
index 7f647cd00..d756894f3 100644
--- a/metrics/metrics.go
+++ b/metrics/metrics.go
@@ -48,6 +48,15 @@ func init() {
exp.Exp(metrics.DefaultRegistry)
}
+// NewCounter create a new metrics Counter, either a real one of a NOP stub depending
+// on the metrics flag.
+func NewCounter(name string) metrics.Counter {
+ if !Enabled {
+ return new(metrics.NilCounter)
+ }
+ return metrics.GetOrRegisterCounter(name, metrics.DefaultRegistry)
+}
+
// NewMeter create a new metrics Meter, either a real one of a NOP stub depending
// on the metrics flag.
func NewMeter(name string) metrics.Meter {