skipper: Index | Files

package tracingtest

import ""

Package tracingtest provides an OpenTracing implementation for testing purposes.


Package Files


type Span Uses

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 NewSpan Uses

func NewSpan(operation string) *Span

func (*Span) BaggageItem Uses

func (s *Span) BaggageItem(key string) string

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 Uses

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) Finish Uses

func (s *Span) Finish()

Sets the end timestamp and finalizes Span state.

func (*Span) FinishWithOptions Uses

func (s *Span) FinishWithOptions(opts tracing.FinishOptions)

FinishWithOptions is like Finish() but with explicit control over timestamps and log data.

func (*Span) ForeachBaggageItem Uses

func (s *Span) ForeachBaggageItem(func(k, v string) bool)

ForeachBaggageItem grants access to all baggage items stored in the SpanContext.

func (*Span) Log Uses

func (*Span) Log(tracing.LogData)

Deprecated: use LogFields or LogKV

func (*Span) LogEvent Uses

func (*Span) LogEvent(string)

Deprecated: use LogFields or LogKV

func (*Span) LogEventWithPayload Uses

func (*Span) LogEventWithPayload(string, interface{})

Deprecated: use LogFields or LogKV

func (*Span) LogFields Uses

func (*Span) LogFields(...log.Field)

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 Uses

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 Uses

func (s *Span) SetBaggageItem(restrictedKey, value string) tracing.Span

SetBaggageItem sets a key:value pair on this Span and its SpanContext that also propagates to descendants of this Span.

func (*Span) SetOperationName Uses

func (s *Span) SetOperationName(operationName string) tracing.Span

Sets or changes the operation name.

func (*Span) SetTag Uses

func (s *Span) SetTag(key string, value interface{}) tracing.Span

Adds a tag to the span.

func (*Span) Tracer Uses

func (s *Span) Tracer() tracing.Tracer

Provides access to the Tracer that created this Span.

type Tracer Uses

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 Uses

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 Uses

func (t *Tracer) FindAllSpans(operationName string) []*Span

FindAllSpans returns all the spans with the defined operation name.

func (*Tracer) FindSpan Uses

func (t *Tracer) FindSpan(operationName string) (*Span, bool)

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 Uses

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.

func (*Tracer) Reset Uses

func (t *Tracer) Reset(traceContent string)

Reset clears the recorded spans and sets the trace content to defined value.

func (*Tracer) StartSpan Uses

func (t *Tracer) StartSpan(operationName string, opts ...tracing.StartSpanOption) tracing.Span

Create, start, and return a new Span with the given `operationName` and incorporate the given StartSpanOption `opts`.

Package tracingtest imports 4 packages (graph). Updated 2019-09-24. Refresh now. Tools for package owners.