gtrace_span.go 675 B

1234567891011121314151617181920212223242526
  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. // Span warps trace.Span for compatibility and extension.
  12. type Span struct {
  13. trace.Span
  14. }
  15. // NewSpan creates a span using default tracer.
  16. func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span) {
  17. ctx, span := NewTracer().Start(ctx, spanName, opts...)
  18. return ctx, &Span{
  19. Span: span,
  20. }
  21. }