rename metrics to meter

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-01-19 16:26:00 +03:00
parent 770e8425bd
commit 74a52eed9d
8 changed files with 193 additions and 61 deletions

47
meter/noop.go Normal file
View File

@@ -0,0 +1,47 @@
package metrics
import (
"time"
"github.com/unistack-org/micro/v3/metadata"
)
// NoopReporter is an noop implementation of Reporter:
type noopReporter struct {
opts Options
}
// NewReporter returns a configured noop reporter:
func NewReporter(opts ...Option) Reporter {
return &noopReporter{
opts: NewOptions(opts...),
}
}
// 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, md metadata.Metadata) error {
return nil
}
// Gauge implements the Reporter interface Gauge method:
func (r *noopReporter) Gauge(metricName string, value float64, md metadata.Metadata) error {
return nil
}
// Timing implements the Reporter interface Timing method:
func (r *noopReporter) Timing(metricName string, value time.Duration, md metadata.Metadata) error {
return nil
}
// Options implements the Reporter interface Optios method:
func (r *noopReporter) Options() Options {
return r.opts
}