Package basictracer
Overview ▹
Index ▹
Variables
var ( BinaryCarrier lightstepBinaryCarrier )
func New ¶
func New(recorder SpanRecorder) opentracing.Tracer
New creates and returns a standard Tracer which defers completed Spans to `recorder`. Spans created by this Tracer support the ext.SamplingPriority tag: Setting ext.SamplingPriority causes the Span to be Sampled from that point on.
func NewWithOptions ¶
func NewWithOptions(opts Options) opentracing.Tracer
NewWithOptions creates a customized Tracer.
type InMemorySpanRecorder ¶
InMemorySpanRecorder is a simple thread-safe implementation of SpanRecorder that stores all reported spans in memory, accessible via reporter.GetSpans(). It is primarily intended for testing purposes.
type InMemorySpanRecorder struct {
sync.RWMutex
// contains filtered or unexported fields
}
func NewInMemoryRecorder ¶
func NewInMemoryRecorder() *InMemorySpanRecorder
NewInMemoryRecorder creates new InMemorySpanRecorder
func (*InMemorySpanRecorder) GetSpans ¶
func (r *InMemorySpanRecorder) GetSpans() []RawSpan
GetSpans returns a copy of the array of spans accumulated so far.
func (*InMemorySpanRecorder) RecordSpan ¶
func (r *InMemorySpanRecorder) RecordSpan(span RawSpan)
RecordSpan implements the respective method of SpanRecorder.
func (*InMemorySpanRecorder) Reset ¶
func (r *InMemorySpanRecorder) Reset()
Reset clears the internal array of spans.
type LightStepStartSpanOption ¶
type LightStepStartSpanOption interface { ApplyLS(*StartSpanOptions) }
type Options ¶
Options allows creating a customized Tracer via NewWithOptions. The object must not be updated when there is an active tracer using it.
type Options struct { // Recorder receives Spans which have been finished. Recorder SpanRecorder // DropAllLogs turns log events on all Spans into no-ops. // If NewSpanEventListener is set, the callbacks will still fire. DropAllLogs bool // MaxLogsPerSpan limits the number of Logs in a span (if set to a nonzero // value). If a span has more logs than this value, logs are dropped as // necessary (and replaced with a log describing how many were dropped). // // About half of the MaxLogPerSpan logs kept are the oldest logs, and about // half are the newest logs. // // If NewSpanEventListener is set, the callbacks will still fire for all log // events. This value is ignored if DropAllLogs is true. MaxLogsPerSpan int }
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns an Options object with a 1 in 64 sampling rate and all options disabled. A Recorder needs to be set manually before using the returned object with a Tracer.
type RawSpan ¶
RawSpan encapsulates all state associated with a (finished) Span.
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 uint64 // The name of the "operation" this span is an instance of. (Called a "span // name" in some implementations) Operation 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 }
type Span ¶
Span provides access to the essential details of the span, for use by basictracer consumers. These methods may only be called prior to (*opentracing.Span).Finish().
type Span interface { opentracing.Span // Operation names the work done by this span instance Operation() string // Start indicates when the span began Start() time.Time }
type SpanContext ¶
SpanContext holds the basic Span metadata.
type SpanContext struct { // A probabilistically unique identifier for a [multi-span] trace. TraceID uint64 // A probabilistically unique identifier for a span. SpanID uint64 // The span's associated baggage. Baggage map[string]string // initialized on first use }
func (SpanContext) ForeachBaggageItem ¶
func (c SpanContext) ForeachBaggageItem(handler func(k, v string) bool)
ForeachBaggageItem belongs to the opentracing.SpanContext interface
func (SpanContext) WithBaggageItem ¶
func (c SpanContext) WithBaggageItem(key, val string) SpanContext
WithBaggageItem returns an entirely new basictracer SpanContext with the given key:value baggage pair set.
type SpanRecorder ¶
A SpanRecorder handles all of the `RawSpan` data generated via an associated `Tracer` (see `NewStandardTracer`) instance. It also names the containing process and provides access to a straightforward tag map.
type SpanRecorder interface {
// Implementations must determine whether and where to store `span`.
RecordSpan(span RawSpan)
}
type StartSpanOptions ¶
type StartSpanOptions struct { Options opentracing.StartSpanOptions // Options to explicitly set span_id, trace_id, // parent_span_id, expected to be used when exporting spans // from another system into LightStep via opentracing APIs. SetSpanID uint64 SetParentSpanID uint64 SetTraceID uint64 }
type Tracer ¶
Tracer extends the opentracing.Tracer interface with methods to probe implementation state, for use by basictracer consumers.
type Tracer interface {
opentracing.Tracer
// Options gets the Options used in New() or NewWithOptions().
Options() Options
}