-
Notifications
You must be signed in to change notification settings - Fork 178
/
noop.go
105 lines (89 loc) · 1.97 KB
/
noop.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package trace
import (
"context"
"go.opentelemetry.io/otel/trace"
"github.com/onflow/flow-go/model/flow"
)
var (
NoopSpan trace.Span = trace.SpanFromContext(context.Background())
)
// NoopTracer is the implementation of the Tracer interface.
// TODO(rbtz): make private
type NoopTracer struct{}
// NewTracer creates a new tracer.
func NewNoopTracer() *NoopTracer {
return &NoopTracer{}
}
// Ready returns a channel that will close when the network stack is ready.
func (t *NoopTracer) Ready() <-chan struct{} {
ready := make(chan struct{})
close(ready)
return ready
}
// Done returns a channel that will close when shutdown is complete.
func (t *NoopTracer) Done() <-chan struct{} {
done := make(chan struct{})
close(done)
return done
}
func (t *NoopTracer) BlockRootSpan(entityID flow.Identifier) trace.Span {
return NoopSpan
}
func (t *NoopTracer) StartBlockSpan(
ctx context.Context,
entityID flow.Identifier,
spanName SpanName,
opts ...trace.SpanStartOption,
) (
trace.Span,
context.Context,
) {
return NoopSpan, ctx
}
func (t *NoopTracer) StartCollectionSpan(
ctx context.Context,
entityID flow.Identifier,
spanName SpanName,
opts ...trace.SpanStartOption,
) (
trace.Span,
context.Context,
) {
return NoopSpan, ctx
}
func (t *NoopTracer) StartSpanFromContext(
ctx context.Context,
operationName SpanName,
opts ...trace.SpanStartOption,
) (
trace.Span,
context.Context,
) {
return NoopSpan, ctx
}
func (t *NoopTracer) StartSpanFromParent(
parentSpan trace.Span,
operationName SpanName,
opts ...trace.SpanStartOption,
) trace.Span {
return NoopSpan
}
func (t *NoopTracer) ShouldSample(entityID flow.Identifier) bool {
return true
}
func (t *NoopTracer) StartSampledSpanFromParent(
parentSpan trace.Span,
entityID flow.Identifier,
operationName SpanName,
opts ...trace.SpanStartOption,
) trace.Span {
return NoopSpan
}
func (t *NoopTracer) WithSpanFromContext(
ctx context.Context,
operationName SpanName,
f func(),
opts ...trace.SpanStartOption,
) {
f()
}