Documentation ¶
Overview ¶
Package tracer provides an OpenTracing compliant Tracer.
Index ¶
- Constants
- Variables
- func FromUUID(id string) string
- func New(reporter SpanReporter, options ...Option) opentracing.Tracer
- func ToUUID(id string) (string, error)
- type CountingReporter
- type DelegatingCarrier
- type DurationSampler
- type Generator
- type GeneratorUUID
- type GeneratorW3C
- type InMemorySpanReporter
- type JaegerOption
- type JaegerWavefrontPropagator
- type NeverSample
- type Option
- type PropagatorW3C
- type RateSampler
- type RawSpan
- type Sampler
- type SpanContext
- type SpanContextPropagator
- type SpanReporter
- type WavefrontTracer
- func (t *WavefrontTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func (t *WavefrontTracer) Inject(sc opentracing.SpanContext, format interface{}, carrier interface{}) error
- func (t *WavefrontTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
- type ZipkinOption
- type ZipkinWavefrontPropagator
Constants ¶
const ( BAGGAGE_PREFIX = "baggage-" TRACE_ID_KEY = "trace-id" PARENT_ID_KEY = "parent-id" SAMPLING_DECISION_KEY = "sampling-decision" )
const ( ZipkinTraceIdKey = zipkinPrefix + "TraceId" ZipkinSpanIdKey = zipkinPrefix + "SpanId" ZipkinParentSpanIdKey = zipkinPrefix + "ParentSpanId" ZipkinSampledKey = zipkinPrefix + "Sampled" ZipkinFlagsKey = zipkinPrefix + "Flags" )
Variables ¶
var ( ErrInvalidZipkinTraceId = fmt.Errorf("%w. Invalid %s found", opentracing.ErrSpanContextCorrupted, ZipkinTraceIdKey) ErrInvalidZipkinSpanId = fmt.Errorf("%w. Invalid %s found", opentracing.ErrSpanContextCorrupted, ZipkinSpanIdKey) ErrInvalidZipkinSampled = errors.New(fmt.Sprintf("invalid %s found", ZipkinSampledKey)) )
var Delegator delegatorType
Delegator is the format to use for DelegatingCarrier.
Functions ¶
func New ¶
func New(reporter SpanReporter, options ...Option) opentracing.Tracer
New creates and returns a WavefrontTracer which defers completed Spans to the given `reporter`.
Types ¶
type CountingReporter ¶
type CountingReporter int32
CountingReporter it is primarily intended for testing purposes.
func (*CountingReporter) Close ¶
func (c *CountingReporter) Close() error
func (*CountingReporter) ReportSpan ¶
func (c *CountingReporter) ReportSpan(r RawSpan)
ReportSpan implements the respective method of SpanReporter.
type DelegatingCarrier ¶
type DelegatingCarrier interface { SetState(traceID string, spanID string, sampled bool) State() (traceID string, spanID string, sampled bool) SetBaggageItem(key, value string) GetBaggage(func(key, value string)) }
DelegatingCarrier is a flexible carrier interface which can be implemented by types which have a means of storing the trace metadata and already know how to serialize themselves (for example, protocol buffers).
type DurationSampler ¶
DurationSampler allows spans above a given duration in milliseconds to be reported.
func (DurationSampler) IsEarly ¶
func (t DurationSampler) IsEarly() bool
IsEarly will return always false
func (DurationSampler) ShouldSample ¶
func (t DurationSampler) ShouldSample(span RawSpan) bool
ShouldSample return true if span duration is bigger than Duration
type Generator ¶ added in v0.9.2
func NewGeneratorUUID ¶ added in v0.9.2
func NewGeneratorUUID() Generator
func NewGeneratorW3C ¶ added in v0.9.2
func NewGeneratorW3C() Generator
type GeneratorUUID ¶ added in v0.9.2
type GeneratorUUID struct {
// contains filtered or unexported fields
}
func (*GeneratorUUID) SpanID ¶ added in v0.9.2
func (g *GeneratorUUID) SpanID() string
func (*GeneratorUUID) TraceID ¶ added in v0.9.2
func (g *GeneratorUUID) TraceID() string
type GeneratorW3C ¶ added in v0.9.2
type GeneratorW3C struct {
// contains filtered or unexported fields
}
func (*GeneratorW3C) SpanID ¶ added in v0.9.2
func (g *GeneratorW3C) SpanID() string
func (*GeneratorW3C) TraceID ¶ added in v0.9.2
func (g *GeneratorW3C) TraceID() string
type InMemorySpanReporter ¶
InMemorySpanReporter is a simple thread-safe implementation of SpanReporter that stores all reported spans in memory, accessible via reporter.getSpans(). It is primarily intended for testing purposes.
func NewInMemoryReporter ¶
func NewInMemoryReporter() *InMemorySpanReporter
NewInMemoryReporter creates new InMemorySpanReporter
func (*InMemorySpanReporter) Close ¶
func (r *InMemorySpanReporter) Close() error
func (*InMemorySpanReporter) ReportSpan ¶
func (r *InMemorySpanReporter) ReportSpan(span RawSpan)
ReportSpan implements the respective method of SpanReporter.
func (*InMemorySpanReporter) Reset ¶
func (r *InMemorySpanReporter) Reset()
Reset clears the internal array of spans.
type JaegerOption ¶
type JaegerOption func(*JaegerWavefrontPropagator)
func WithBaggagePrefix ¶
func WithBaggagePrefix(baggagePrefix string) JaegerOption
func WithTraceIdHeader ¶
func WithTraceIdHeader(traceIdHeader string) JaegerOption
type JaegerWavefrontPropagator ¶
type JaegerWavefrontPropagator struct {
// contains filtered or unexported fields
}
func NewJaegerWavefrontPropagator ¶
func NewJaegerWavefrontPropagator(tracer *WavefrontTracer, options []JaegerOption) *JaegerWavefrontPropagator
func (*JaegerWavefrontPropagator) Extract ¶
func (p *JaegerWavefrontPropagator) Extract(opaqueCarrier interface{}) (spanCtx SpanContext, err error)
func (*JaegerWavefrontPropagator) Inject ¶
func (p *JaegerWavefrontPropagator) Inject(spanContext opentracing.SpanContext, opaqueCarrier interface{}) error
type NeverSample ¶
type NeverSample struct{}
NeverSample basic sampler to not sample any Spans
func (NeverSample) ShouldSample ¶
func (t NeverSample) ShouldSample(span RawSpan) bool
ShouldSample allways false
type Option ¶
type Option func(*WavefrontTracer)
Option allows customizing the WavefrontTracer.
func WithGenerator ¶ added in v0.9.3
WithGenerator configures Tracer to use a custom trace id generator implementation.
func WithJaegerPropagator ¶
WithJaegerPropagator configures Tracer to use Jaeger trace context propagation.
func WithW3CGenerator ¶ added in v0.9.2
func WithW3CGenerator() Option
WithW3CGenerator configures Tracer to generate Trace and Span IDs according to W3C spec.
func WithW3CPropagator ¶ added in v0.9.2
func WithW3CPropagator() Option
WithW3CPropagator configures Tracer to use trace context propagation according to W3C spec.
func WithZipkinPropagator ¶ added in v0.10.0
func WithZipkinPropagator(zipkinOptions ...ZipkinOption) Option
WithZipkinPropagator configures Tracer to use Zipkin trace context propagation.
type PropagatorW3C ¶ added in v0.9.2
type PropagatorW3C struct { }
PropagatorW3C implements trace context propagation according to W3C definition https://www.w3.org/TR/trace-context/
func (*PropagatorW3C) Extract ¶ added in v0.9.2
func (p *PropagatorW3C) Extract(opaqueCarrier interface{}) (opentracing.SpanContext, error)
func (*PropagatorW3C) Inject ¶ added in v0.9.2
func (p *PropagatorW3C) Inject(spanContext opentracing.SpanContext, opaqueCarrier interface{}) error
type RateSampler ¶
type RateSampler struct {
Rate uint64
}
RateSampler allows spans based on a rate
func (RateSampler) ShouldSample ¶
func (t RateSampler) ShouldSample(span RawSpan) bool
ShouldSample return true based on a rate
type RawSpan ¶
type RawSpan struct { // Those recording the RawSpan should also record the contents of its // SpanContext. Context SpanContext // The SpanID of this SpanContext's first intra-trace reference (i.e., // "parent"), or 0 if there is no parent. ParentSpanID string References []opentracing.SpanReference // The name of the "operation" this span is an instance of. (Called a "span name" in some implementations) Operation string // The name of the "component" this span is associated with. Can be empty. Component string // We store <start, duration> rather than <start, end> so that only // one of the timestamps has global clock uncertainty issues. Start time.Time Duration time.Duration // Essentially an extension mechanism. Can be used for many purposes, // not to be enumerated here. Tags opentracing.Tags // The span's "microlog". Logs []opentracing.LogRecord }
RawSpan holds the span information
type SpanContext ¶
type SpanContext struct { // A probabilistically unique identifier for a [multi-span] trace. TraceID string // A probabilistically unique identifier for a span. SpanID string // Whether the trace is sampled. Sampled *bool // The span's associated baggage. Baggage map[string]string // initialized on first use }
SpanContext holds the basic Span metadata.
func (SpanContext) ForeachBaggageItem ¶
func (c SpanContext) ForeachBaggageItem(handler func(k, v string) bool)
ForeachBaggageItem belongs to the opentracing.SpanContext interface
func (SpanContext) IsSampled ¶
func (c SpanContext) IsSampled() bool
func (SpanContext) SamplingDecision ¶
func (c SpanContext) SamplingDecision() *bool
func (SpanContext) WithBaggageItem ¶
func (c SpanContext) WithBaggageItem(key, val string) SpanContext
WithBaggageItem returns an entirely new SpanContext with the given key:value baggage pair set.
type SpanContextPropagator ¶ added in v0.9.2
type SpanContextPropagator interface { Inject(spanContext opentracing.SpanContext, carrier interface{}) error Extract(carrier interface{}) (opentracing.SpanContext, error) }
SpanContextPropagator implements SpanContext propagation to/from another processes.
func NewPropagatorW3C ¶ added in v0.9.2
func NewPropagatorW3C() SpanContextPropagator
NewPropagatorW3C creates PropagatorW3C instance.
type SpanReporter ¶
SpanReporter reports completed Spans
type WavefrontTracer ¶
type WavefrontTracer struct {
// contains filtered or unexported fields
}
WavefrontTracer implements the OpenTracing `Tracer` interface.
func (*WavefrontTracer) Extract ¶
func (t *WavefrontTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
func (*WavefrontTracer) Inject ¶
func (t *WavefrontTracer) Inject(sc opentracing.SpanContext, format interface{}, carrier interface{}) error
func (*WavefrontTracer) StartSpan ¶
func (t *WavefrontTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
type ZipkinOption ¶ added in v0.10.0
type ZipkinOption func(*ZipkinWavefrontPropagator)
func WithOverrideSamplingDecision ¶ added in v0.10.0
func WithOverrideSamplingDecision(samplingDecision bool) ZipkinOption
WithOverrideSamplingDecision configures ZipkinWavefrontPropagator to override sampling (X-B3-Sampled) with following samplingDecision:
true: Accept
false: Deny
type ZipkinWavefrontPropagator ¶ added in v0.10.0
type ZipkinWavefrontPropagator struct {
// contains filtered or unexported fields
}
func NewZipkinWavefrontPropagator ¶ added in v0.10.0
func NewZipkinWavefrontPropagator(opts ...ZipkinOption) *ZipkinWavefrontPropagator
func (*ZipkinWavefrontPropagator) Extract ¶ added in v0.10.0
func (z *ZipkinWavefrontPropagator) Extract(opaqueCarrier interface{}) (SpanContext, error)
func (*ZipkinWavefrontPropagator) Inject ¶ added in v0.10.0
func (z *ZipkinWavefrontPropagator) Inject(spanContext opentracing.SpanContext, opaqueCarrier interface{}) error