github.com/iotexproject/iotex-core@v1.14.1-rc1/pkg/tracer/span.go (about)

     1  package tracer
     2  
     3  import (
     4  	"context"
     5  
     6  	"go.opentelemetry.io/otel"
     7  	"go.opentelemetry.io/otel/trace"
     8  )
     9  
    10  // NewSpan returns a new span from the global tracer.
    11  // span must be completed with `defer span.End()` right after the call.
    12  func NewSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
    13  	return otel.Tracer("").Start(ctx, name, opts...)
    14  }
    15  
    16  // SpanFromContext returns the current span from a context.
    17  func SpanFromContext(ctx context.Context) trace.Span {
    18  	return trace.SpanFromContext(ctx)
    19  }