github.com/koko1123/flow-go-1@v0.29.6/module/trace/noop.go (about)

     1  package trace
     2  
     3  import (
     4  	"context"
     5  
     6  	"go.opentelemetry.io/otel/trace"
     7  
     8  	"github.com/koko1123/flow-go-1/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) StartBlockSpan(
    39  	ctx context.Context,
    40  	entityID flow.Identifier,
    41  	spanName SpanName,
    42  	opts ...trace.SpanStartOption,
    43  ) (
    44  	trace.Span,
    45  	context.Context,
    46  ) {
    47  	return NoopSpan, ctx
    48  }
    49  
    50  func (t *NoopTracer) StartCollectionSpan(
    51  	ctx context.Context,
    52  	entityID flow.Identifier,
    53  	spanName SpanName,
    54  	opts ...trace.SpanStartOption,
    55  ) (
    56  	trace.Span,
    57  	context.Context,
    58  ) {
    59  	return NoopSpan, ctx
    60  }
    61  
    62  func (t *NoopTracer) StartTransactionSpan(
    63  	ctx context.Context,
    64  	entityID flow.Identifier,
    65  	spanName SpanName,
    66  	opts ...trace.SpanStartOption,
    67  ) (
    68  	trace.Span,
    69  	context.Context,
    70  ) {
    71  	return NoopSpan, ctx
    72  }
    73  
    74  func (t *NoopTracer) StartSpanFromContext(
    75  	ctx context.Context,
    76  	operationName SpanName,
    77  	opts ...trace.SpanStartOption,
    78  ) (
    79  	trace.Span,
    80  	context.Context,
    81  ) {
    82  	return NoopSpan, ctx
    83  }
    84  
    85  func (t *NoopTracer) StartSpanFromParent(
    86  	parentSpan trace.Span,
    87  	operationName SpanName,
    88  	opts ...trace.SpanStartOption,
    89  ) trace.Span {
    90  	return NoopSpan
    91  }
    92  
    93  func (t *NoopTracer) WithSpanFromContext(
    94  	ctx context.Context,
    95  	operationName SpanName,
    96  	f func(),
    97  	opts ...trace.SpanStartOption,
    98  ) {
    99  	f()
   100  }