Files
gf/net/gtrace/gtrace_span.go

27 lines
675 B
Go
Raw Permalink Normal View History

2021-01-28 13:11:09 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gtrace
import (
"context"
2021-01-28 13:11:09 +08:00
"go.opentelemetry.io/otel/trace"
)
2021-09-22 19:12:31 +08:00
// Span warps trace.Span for compatibility and extension.
2021-01-28 13:11:09 +08:00
type Span struct {
trace.Span
}
// NewSpan creates a span using default tracer.
2021-06-24 16:29:55 +08:00
func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span) {
2021-01-28 13:11:09 +08:00
ctx, span := NewTracer().Start(ctx, spanName, opts...)
return ctx, &Span{
Span: span,
}
}