gtrace_span.go 616 B

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