github.com/wangyougui/gf/v2@v2.6.5/net/gtrace/gtrace_span.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gtrace
     8  
     9  import (
    10  	"context"
    11  
    12  	"go.opentelemetry.io/otel/trace"
    13  )
    14  
    15  // Span warps trace.Span for compatibility and extension.
    16  type Span struct {
    17  	trace.Span
    18  }
    19  
    20  // NewSpan creates a span using default tracer.
    21  func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span) {
    22  	ctx, span := NewTracer().Start(ctx, spanName, opts...)
    23  	return ctx, &Span{
    24  		Span: span,
    25  	}
    26  }