Documentation ¶
Overview ¶
Package tracingtest provides an OpenTracing implementation for testing purposes.
Index ¶
- type Span
- func (s *Span) BaggageItem(key string) string
- func (s *Span) Context() tracing.SpanContext
- func (s *Span) Finish()
- func (s *Span) FinishWithOptions(opts tracing.FinishOptions)
- func (s *Span) ForeachBaggageItem(func(k, v string) bool)
- func (*Span) Log(tracing.LogData)deprecated
- func (*Span) LogEvent(string)deprecated
- func (*Span) LogEventWithPayload(string, interface{})deprecated
- func (*Span) LogFields(...log.Field)
- func (*Span) LogKV(...interface{})
- func (s *Span) SetBaggageItem(restrictedKey, value string) tracing.Span
- func (s *Span) SetOperationName(operationName string) tracing.Span
- func (s *Span) SetTag(key string, value interface{}) tracing.Span
- func (s *Span) Tracer() tracing.Tracer
- type Tracer
- func (t *Tracer) Extract(format interface{}, carrier interface{}) (tracing.SpanContext, error)
- func (t *Tracer) FindAllSpans(operationName string) []*Span
- func (t *Tracer) FindSpan(operationName string) (*Span, bool)
- func (t *Tracer) Inject(sm tracing.SpanContext, format interface{}, carrier interface{}) error
- func (t *Tracer) Reset(traceContent string)
- func (t *Tracer) StartSpan(operationName string, opts ...tracing.StartSpanOption) tracing.Span
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Span ¶
type Span struct { // Trace contains the current trace as string. Trace string // Refs contain the collected spans. Refs []tracing.SpanReference // StartTime contains the timestamp when the span was started. StartTime time.Time // FinishTime contains the timestamp when the span was finished. FinishTime time.Time Tags map[string]interface{} // contains filtered or unexported fields }
Span is an implementation of the opentracing.Span interface for testing.
func (*Span) BaggageItem ¶
Gets the value for a baggage item given its key. Returns the empty string if the value isn't found in this Span.
func (*Span) Context ¶
func (s *Span) Context() tracing.SpanContext
Context() yields the SpanContext for this Span. Note that the return value of Context() is still valid after a call to Span.Finish(), as is a call to Span.Context() after a call to Span.Finish().
func (*Span) FinishWithOptions ¶
func (s *Span) FinishWithOptions(opts tracing.FinishOptions)
FinishWithOptions is like Finish() but with explicit control over timestamps and log data.
func (*Span) ForeachBaggageItem ¶
ForeachBaggageItem grants access to all baggage items stored in the SpanContext.
func (*Span) LogEventWithPayload
deprecated
func (*Span) LogFields ¶
LogFields is an efficient and type-checked way to record key:value logging data about a Span, though the programming interface is a little more verbose than LogKV().
func (*Span) LogKV ¶
func (*Span) LogKV(...interface{})
LogKV is a concise, readable way to record key:value logging data about a Span, though unfortunately this also makes it less efficient and less type-safe than LogFields().
func (*Span) SetBaggageItem ¶
SetBaggageItem sets a key:value pair on this Span and its SpanContext that also propagates to descendants of this Span.
func (*Span) SetOperationName ¶
Sets or changes the operation name.
type Tracer ¶
type Tracer struct { // TraceContent represents the tracing content passed along the wire. // The test tracer considers it an opaque value and doesn't modify it. TraceContent string // RecordedSpans contains the collected spans. RecordedSpans []*Span }
Tracer is an implementation of opentracing.Tracer for testing. It records the defined spans during a series of operations.
func (*Tracer) Extract ¶
func (t *Tracer) Extract(format interface{}, carrier interface{}) (tracing.SpanContext, error)
Extract() returns a SpanContext instance given `format` and `carrier`.
It copies the X-Trace-Header value to the TraceContent field.
func (*Tracer) FindAllSpans ¶
FindAllSpans returns all the spans with the defined operation name.
func (*Tracer) FindSpan ¶
FindSpan returns the first span with the defined operation name and true, if at least one was collected, otherwise nil and false.
func (*Tracer) Inject ¶
func (t *Tracer) Inject(sm tracing.SpanContext, format interface{}, carrier interface{}) error
Inject() takes the `sm` SpanContext instance and injects it for propagation within `carrier`.
It sets the X-Trace-Header to the value of TraceContent.