2020-11-15 00:38:38 +03:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
2020-11-18 16:50:41 +03:00
|
|
|
|
|
|
|
"github.com/unistack-org/micro/v3/metadata"
|
2020-11-15 00:38:38 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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...),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-15 00:53:40 +03:00
|
|
|
// Init initialize options
|
|
|
|
func (r *noopReporter) Init(opts ...Option) error {
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&r.opts)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-15 00:38:38 +03:00
|
|
|
// Count implements the Reporter interface Count method:
|
2020-11-18 16:50:41 +03:00
|
|
|
func (r *noopReporter) Count(metricName string, value int64, md metadata.Metadata) error {
|
2020-11-15 00:38:38 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gauge implements the Reporter interface Gauge method:
|
2020-11-18 16:50:41 +03:00
|
|
|
func (r *noopReporter) Gauge(metricName string, value float64, md metadata.Metadata) error {
|
2020-11-15 00:38:38 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Timing implements the Reporter interface Timing method:
|
2020-11-18 16:50:41 +03:00
|
|
|
func (r *noopReporter) Timing(metricName string, value time.Duration, md metadata.Metadata) error {
|
2020-11-15 00:38:38 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Options implements the Reporter interface Optios method:
|
|
|
|
func (r *noopReporter) Options() Options {
|
|
|
|
return r.opts
|
|
|
|
}
|