-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathnop.go
32 lines (22 loc) · 901 Bytes
/
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
package tracing
import "context"
// NopTracerProvider is a no-op tracing implementation.
type NopTracerProvider struct{}
var _ TracerProvider = (*NopTracerProvider)(nil)
// Tracer returns a tracer which creates no-op spans.
func (NopTracerProvider) Tracer(string, ...TracerOption) Tracer {
return nopTracer{}
}
type nopTracer struct{}
var _ Tracer = (*nopTracer)(nil)
func (nopTracer) StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) {
return ctx, nopSpan{}
}
type nopSpan struct{}
var _ Span = (*nopSpan)(nil)
func (nopSpan) Name() string { return "" }
func (nopSpan) Context() SpanContext { return SpanContext{} }
func (nopSpan) AddEvent(string, ...EventOption) {}
func (nopSpan) SetProperty(any, any) {}
func (nopSpan) SetStatus(SpanStatus) {}
func (nopSpan) End() {}