github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/trace/noop.go (about) 1 package trace 2 3 import ( 4 "context" 5 6 "go.opentelemetry.io/otel/trace" 7 8 "github.com/onflow/flow-go/model/flow" 9 ) 10 11 var ( 12 NoopSpan trace.Span = trace.SpanFromContext(context.Background()) 13 ) 14 15 // NoopTracer is the implementation of the Tracer interface. 16 // TODO(rbtz): make private 17 type NoopTracer struct{} 18 19 // NewTracer creates a new tracer. 20 func NewNoopTracer() *NoopTracer { 21 return &NoopTracer{} 22 } 23 24 // Ready returns a channel that will close when the network stack is ready. 25 func (t *NoopTracer) Ready() <-chan struct{} { 26 ready := make(chan struct{}) 27 close(ready) 28 return ready 29 } 30 31 // Done returns a channel that will close when shutdown is complete. 32 func (t *NoopTracer) Done() <-chan struct{} { 33 done := make(chan struct{}) 34 close(done) 35 return done 36 } 37 38 func (t *NoopTracer) BlockRootSpan(entityID flow.Identifier) trace.Span { 39 return NoopSpan 40 } 41 42 func (t *NoopTracer) StartBlockSpan( 43 ctx context.Context, 44 entityID flow.Identifier, 45 spanName SpanName, 46 opts ...trace.SpanStartOption, 47 ) ( 48 trace.Span, 49 context.Context, 50 ) { 51 return NoopSpan, ctx 52 } 53 54 func (t *NoopTracer) StartCollectionSpan( 55 ctx context.Context, 56 entityID flow.Identifier, 57 spanName SpanName, 58 opts ...trace.SpanStartOption, 59 ) ( 60 trace.Span, 61 context.Context, 62 ) { 63 return NoopSpan, ctx 64 } 65 66 func (t *NoopTracer) StartSpanFromContext( 67 ctx context.Context, 68 operationName SpanName, 69 opts ...trace.SpanStartOption, 70 ) ( 71 trace.Span, 72 context.Context, 73 ) { 74 return NoopSpan, ctx 75 } 76 77 func (t *NoopTracer) StartSpanFromParent( 78 parentSpan trace.Span, 79 operationName SpanName, 80 opts ...trace.SpanStartOption, 81 ) trace.Span { 82 return NoopSpan 83 } 84 85 func (t *NoopTracer) ShouldSample(entityID flow.Identifier) bool { 86 return true 87 } 88 89 func (t *NoopTracer) StartSampledSpanFromParent( 90 parentSpan trace.Span, 91 entityID flow.Identifier, 92 operationName SpanName, 93 opts ...trace.SpanStartOption, 94 ) trace.Span { 95 return NoopSpan 96 } 97 98 func (t *NoopTracer) WithSpanFromContext( 99 ctx context.Context, 100 operationName SpanName, 101 f func(), 102 opts ...trace.SpanStartOption, 103 ) { 104 f() 105 }