From e0ef8b2953b53dd93fa87766ab3646dae53a2dfe Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 15 Nov 2020 00:53:40 +0300 Subject: [PATCH] merics: add Init func to interface Signed-off-by: Vasiliy Tolstov --- metrics/noop.go | 8 ++++++++ metrics/reporter.go | 1 + 2 files changed, 9 insertions(+) diff --git a/metrics/noop.go b/metrics/noop.go index 8f210b77..ffb4e143 100644 --- a/metrics/noop.go +++ b/metrics/noop.go @@ -16,6 +16,14 @@ func NewReporter(opts ...Option) Reporter { } } +// Init initialize options +func (r *noopReporter) Init(opts ...Option) error { + for _, o := range opts { + o(&r.opts) + } + return nil +} + // Count implements the Reporter interface Count method: func (r *noopReporter) Count(metricName string, value int64, tags Tags) error { return nil diff --git a/metrics/reporter.go b/metrics/reporter.go index 84f998f6..b0e45197 100644 --- a/metrics/reporter.go +++ b/metrics/reporter.go @@ -12,6 +12,7 @@ var ( // Reporter is an interface for collecting and instrumenting metrics type Reporter interface { + Init(...Option) error Count(id string, value int64, tags Tags) error Gauge(id string, value float64, tags Tags) error Timing(id string, value time.Duration, tags Tags) error