github.com/gogf/gf@v1.16.9/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/gogf/gf.
     6  
     7  package gtrace
     8  
     9  import (
    10  	"context"
    11  	"go.opentelemetry.io/otel/trace"
    12  )
    13  
    14  type Span struct {
    15  	trace.Span
    16  }
    17  
    18  // NewSpan creates a span using default tracer.
    19  func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span) {
    20  	ctx, span := NewTracer().Start(ctx, spanName, opts...)
    21  	return ctx, &Span{
    22  		Span: span,
    23  	}
    24  }