tracer

package
v0.0.0-...-0c7ab9d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package tracer provides an OpenTracing compliant Tracer.

Index

Constants

View Source
const (
	BAGGAGE_PREFIX        = "baggage-"
	TRACE_ID_KEY          = "trace-id"
	PARENT_ID_KEY         = "parent-id"
	SAMPLING_DECISION_KEY = "sampling-decision"
)

Variables

View Source
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`.

func ToUUID

func ToUUID(id string) (string, error)

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

type DurationSampler struct {
	Duration time.Duration
}

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 InMemorySpanReporter

type InMemorySpanReporter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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{}) (SpanContext,
	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) IsEarly

func (t NeverSample) IsEarly() bool

IsEarly will return always true

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 WithJaegerPropagator

func WithJaegerPropagator(traceId, baggagePrefix string) Option

func WithSampler

func WithSampler(sampler Sampler) Option

WithSampler defines a Sampler

type RateSampler

type RateSampler struct {
	Rate uint64
}

RateSampler allows spans based on a rate

func (RateSampler) IsEarly

func (t RateSampler) IsEarly() bool

IsEarly will return always true

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 Sampler

type Sampler interface {
	ShouldSample(span RawSpan) bool
	IsEarly() bool
}

Sampler controls whether a span should be sampled/reported

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 SpanReporter

type SpanReporter interface {
	io.Closer
	ReportSpan(span RawSpan)
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL