/
nop.go
41 lines (30 loc) · 1.05 KB
/
nop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package stats
import (
"context"
"time"
"go.opentelemetry.io/otel/trace/noop"
)
var NOP Stats = &nop{}
type nop struct{}
type nopMeasurement struct{}
func (nopMeasurement) Count(_ int) {}
func (nopMeasurement) Increment() {}
func (nopMeasurement) Gauge(_ any) {}
func (nopMeasurement) Observe(_ float64) {}
func (nopMeasurement) SendTiming(_ time.Duration) {}
func (nopMeasurement) Since(_ time.Time) {}
func (nopMeasurement) RecordDuration() func() { return func() {} }
func (*nop) NewStat(_, _ string) Measurement {
return &nopMeasurement{}
}
func (*nop) NewTaggedStat(_, _ string, _ Tags) Measurement {
return &nopMeasurement{}
}
func (*nop) NewSampledTaggedStat(_, _ string, _ Tags) Measurement {
return &nopMeasurement{}
}
func (*nop) NewTracer(_ string) Tracer {
return NewTracerFromOpenTelemetry(noop.NewTracerProvider().Tracer(""))
}
func (*nop) Start(_ context.Context, _ GoRoutineFactory) error { return nil }
func (*nop) Stop() {}