Documentation
¶
Index ¶
- Constants
- Variables
- func Extract(tracer opentracing.Tracer, header http.Header) (opentracing.SpanContext, error)
- func InjectHeaders(span opentracing.Span, request *http.Request) error
- func RegisterFactory(name string, r Factory)
- func SetIfCtxErr(span opentracing.Span, ctx context.Context)
- func SetIfErr(span opentracing.Span, err error)
- type Cfg
- type Factory
- type HandlerFunc
- type RequestFunc
- type Span
- func CreateChild(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span
- func CreateFollows(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span
- func GetFrom(ctx context.Context) *Span
- func NewSpan(sp opentracing.Span) *Span
- func StartSpan(operationName string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) CreateChild(name string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) CreateFollows(name string, opts ...opentracing.StartSpanOption) *Span
- func (s *Span) GetHttpHeader() http.Header
- func (s *Span) SetBaggageItem(restrictedKey, value string) opentracing.Span
- func (s *Span) SetOperationName(name string) opentracing.Span
- func (s *Span) SetTag(key string, value interface{}) opentracing.Span
- func (s *Span) SpanID() (string, string)
- func (s *Span) WithCtx(ctx context.Context) context.Context
Constants ¶
const (
KeyErrMsg = "err_msg"
)
const Name = "tracing"
Variables ¶
var GetSpanID = func(ctx opentracing.SpanContext) (string, string) { return "", "" }
GetSpanID 从SpanContext中获取spanID
Functions ¶
func Extract ¶
func Extract(tracer opentracing.Tracer, header http.Header) (opentracing.SpanContext, error)
Extract extracts the inbound HTTP request to obtain the parent span's context to ensure correct propagation of span context throughout the trace.
func InjectHeaders ¶
func InjectHeaders(span opentracing.Span, request *http.Request) error
InjectHeaders injects the outbound HTTP request with the given span's context to ensure correct propagation of span context throughout the trace.
func RegisterFactory ¶
func SetIfCtxErr ¶
func SetIfCtxErr(span opentracing.Span, ctx context.Context)
SetIfCtxErr record context error
Types ¶
type Cfg ¶
type Cfg struct {
Driver string `json:"driver"`
DriverCfg map[string]interface{} `json:"driver_config"`
}
func DefaultCfg ¶
func DefaultCfg() Cfg
type Factory ¶
func GetFactory ¶
type HandlerFunc ¶
HandlerFunc is a middleware function for incoming HTTP requests.
func FromHTTPRequest ¶
func FromHTTPRequest(tracer opentracing.Tracer, operationName string) HandlerFunc
FromHTTPRequest returns a Middleware HandlerFunc that tries to join with an OpenTracing trace found in the HTTP request headers and starts a new Span called `operationName`. If no trace could be found in the HTTP request headers, the Span will be a trace root. The Span is incorporated in the HTTP Context object and can be retrieved with opentracing.SpanFromContext(ctx).
type RequestFunc ¶
RequestFunc is a middleware function for outgoing HTTP requests.
func ToHTTPRequest ¶
func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc
ToHTTPRequest returns a RequestFunc that injects an OpenTracing Span found in context into the HTTP Headers. If no such Span can be found, the RequestFunc is a noop.
type Span ¶
type Span struct {
opentracing.Span
}
func CreateChild ¶
func CreateChild(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span
func CreateFollows ¶
func CreateFollows(ctx context.Context, name string, opts ...opentracing.StartSpanOption) *Span
func NewSpan ¶
func NewSpan(sp opentracing.Span) *Span
func StartSpan ¶
func StartSpan(operationName string, opts ...opentracing.StartSpanOption) *Span
func (*Span) CreateChild ¶
func (s *Span) CreateChild(name string, opts ...opentracing.StartSpanOption) *Span
func (*Span) CreateFollows ¶
func (s *Span) CreateFollows(name string, opts ...opentracing.StartSpanOption) *Span
func (*Span) GetHttpHeader ¶
func (*Span) SetBaggageItem ¶
func (s *Span) SetBaggageItem(restrictedKey, value string) opentracing.Span
func (*Span) SetOperationName ¶
func (s *Span) SetOperationName(name string) opentracing.Span