Documentation ¶
Index ¶
- Constants
- Variables
- func CloseGlobalTracer()
- func ContextWithSpan(ctx context.Context, span Span) context.Context
- func Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func GetTraceIDKey() string
- func InjectWithHTTPHeader(ctx context.Context, r *http.Request) error
- func SetGlobalTracer(tracer *Tracer)
- type HTTPHeadersCarrier
- type ID
- type Options
- type Span
- func SpanFromContext(ctx context.Context) Span
- func SpanFromContextSafe(ctx context.Context) Span
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (Span, context.Context)
- func StartSpanFromContextWithTraceID(ctx context.Context, operationName string, traceID string, ...) (Span, context.Context)
- func StartSpanFromHTTPHeaderSafe(r *http.Request, operationName string) (Span, context.Context)
- type SpanContext
- type StartTime
- type Tag
- type Tags
- type TextMapCarrier
- type TextMapPropagator
- type Tracer
- func (t *Tracer) Close() error
- func (t *Tracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func (t *Tracer) Inject(sc opentracing.SpanContext, format interface{}, carrier interface{}) error
- func (t *Tracer) StartSpan(operationName string, options ...opentracing.StartSpanOption) opentracing.Span
- type TracerOption
Constants ¶
const ( // Binary is the alias of opentracing.Binary. Binary = opentracing.Binary // TextMap is the alias of opentracing.TextMap. TextMap = opentracing.TextMap // HTTPHeaders is the alias of opentracing.HTTPHeaders. HTTPHeaders = opentracing.HTTPHeaders )
Variables ¶
var ( // ErrUnsupportedFormat is the alias of opentracing.ErrUnsupportedFormat. ErrUnsupportedFormat = opentracing.ErrUnsupportedFormat // ErrSpanContextNotFound is the alias of opentracing.ErrSpanContextNotFound. ErrSpanContextNotFound = opentracing.ErrSpanContextNotFound // ErrInvalidSpanContext is the alias of opentracing.ErrInvalidSpanContext. ErrInvalidSpanContext = opentracing.ErrInvalidSpanContext // ErrInvalidCarrier is the alias of opentracing.ErrInvalidCarrier. ErrInvalidCarrier = opentracing.ErrInvalidCarrier // ErrSpanContextCorrupted is the alias of opentracing.ErrSpanContextCorrupted. ErrSpanContextCorrupted = opentracing.ErrSpanContextCorrupted )
var ChildOf = opentracing.ChildOf
ChildOf is the alias of opentracing.ChildOf
var FollowsFrom = opentracing.FollowsFrom
FollowsFrom is the alias of opentracing.FollowsFrom
var TracerOptions tracerOptions
TracerOptions is a factory for all available TracerOption's
Functions ¶
func CloseGlobalTracer ¶
func CloseGlobalTracer()
CloseGlobalTracer closes global tracer gracefully.
func ContextWithSpan ¶
ContextWithSpan returns a new `context.Context` that holds a reference to the span. If span is nil, a new context without an active span is returned.
func Extract ¶
func Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
Extract returns a SpanContext instance given `format` and `carrier`.
func InjectWithHTTPHeader ¶
InjectWithHTTPHeader takes the `sm` SpanContext instance and injects it for propagation within `HTTPHeadersCarrier` and `HTTPHeaders`.
func SetGlobalTracer ¶
func SetGlobalTracer(tracer *Tracer)
SetGlobalTracer sets the [singleton] opentracing.Tracer returned by GlobalTracer(). Those who use GlobalTracer (rather than directly manage an opentracing.Tracer instance) should call SetGlobalTracer as early as possible in main(), prior to calling the `StartSpan` global func below. Prior to calling `SetGlobalTracer`, any Spans started via the `StartSpan` (etc) globals are noops.
Types ¶
type HTTPHeadersCarrier ¶
type HTTPHeadersCarrier = opentracing.HTTPHeadersCarrier
HTTPHeadersCarrier is the alias of opentracing.HTTPHeadersCarrier.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options tracer options
type Span ¶
type Span interface { opentracing.Span // OperationName allows retrieving current operation name. OperationName() string // Tags returns tags for span Tags() Tags // Logs returns micro logs for span Logs() []opentracing.LogRecord // String returns traceID:spanID. String() string // TraceID returns traceID TraceID() string // AppendRPCTrackLog appends RPC track logs to baggage with default key fieldTrackLogKey. AppendRPCTrackLog(logs []string) // AppendTrackLog records cost time with startTime (duration=time.Since(startTime)) for a calling to a module and // appends to baggage with default key fieldTrackLogKey. AppendTrackLog(module string, startTime time.Time, err error) // AppendTrackLogWithDuration records cost time with duration for a calling to a module and // appends to baggage with default key fieldTrackLogKey. AppendTrackLogWithDuration(module string, duration time.Duration, err error) // TrackLog returns track log, calls BaggageItem with default key fieldTrackLogKey. TrackLog() []string // BaseLogger defines interface of application log apis. log.BaseLogger }
Span extends opentracing.Span
func SpanFromContext ¶
SpanFromContext returns the `Span` previously associated with `ctx`, or `nil` if no such `Span` could be found.
func SpanFromContextSafe ¶
SpanFromContextSafe returns the `Span` previously associated with `ctx`, or creates a root Span with name default.
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (Span, context.Context)
StartSpanFromContext starts and returns a Span with `operationName`, using any Span found within `ctx` as a ChildOfRef. If no such parent could be found, StartSpanFromContext creates a root (parentless) Span.
type SpanContext ¶
SpanContext implements opentracing.SpanContext
func (*SpanContext) ForeachBaggageItem ¶
func (s *SpanContext) ForeachBaggageItem(handler func(k, v string) bool)
ForeachBaggageItem implements opentracing.SpanContext API
func (*SpanContext) ForeachBaggageItems ¶
func (s *SpanContext) ForeachBaggageItems(handler func(k string, v []string) bool)
ForeachBaggageItems will called the handler function for each baggage key/values pair.
func (*SpanContext) IsEmpty ¶
func (s *SpanContext) IsEmpty() bool
IsEmpty returns true is span context is empty
func (*SpanContext) IsValid ¶
func (s *SpanContext) IsValid() bool
IsValid returns true if SpanContext is valid
type StartTime ¶
type StartTime = opentracing.StartTime
StartTime is alias of opentracing.StartTime.
type Tags ¶
type Tags opentracing.Tags
Tags are the expand of opentracing.Tags
type TextMapCarrier ¶
type TextMapCarrier = opentracing.TextMapCarrier
TextMapCarrier is the alias of opentracing.TextMapCarrier.
type TextMapPropagator ¶
type TextMapPropagator struct{}
TextMapPropagator is a combined Injector and Extractor for TextMap format.
func (*TextMapPropagator) Extract ¶
func (t *TextMapPropagator) Extract(carrier interface{}) (opentracing.SpanContext, error)
Extract implements Extractor of TextMapPropagator.
func (*TextMapPropagator) Inject ¶
func (t *TextMapPropagator) Inject(sc *SpanContext, carrier interface{}) error
Inject implements Injector of TextMapPropagator
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer implements opentracing.Tracer
func GlobalTracer ¶
func GlobalTracer() *Tracer
GlobalTracer returns the global singleton `Tracer` implementation.
func NewTracer ¶
func NewTracer(serviceName string, opts ...TracerOption) *Tracer
NewTracer creates a tracer with serviceName
func (*Tracer) StartSpan ¶
func (t *Tracer) StartSpan(operationName string, options ...opentracing.StartSpanOption) opentracing.Span
StartSpan implements StartSpan() method of opentracing.Tracer. Create, start, and return a new Span with the given `operationName` and incorporate the given StartSpanOption `opts`.
type TracerOption ¶
type TracerOption func(tracer *Tracer)
TracerOption is a function that sets some option on the tracer