tracingtest

package
v0.10.48 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package tracingtest provides an OpenTracing implementation for testing purposes.

Index

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
	// contains filtered or unexported fields
}

Span is an implementation of the opentracing.Span interface for testing.

func (*Span) BaggageItem

func (*Span) BaggageItem(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

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

func (s *Span) Finish()

Sets the end timestamp and finalizes Span state.

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

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

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

func (*Span) Log deprecated

func (*Span) Log(tracing.LogData)

Deprecated: use LogFields or LogKV

func (*Span) LogEvent deprecated

func (*Span) LogEvent(string)

Deprecated: use LogFields or LogKV

func (*Span) LogEventWithPayload deprecated

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

Deprecated: use LogFields or LogKV

func (*Span) LogFields

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

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

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

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

Sets or changes the operation name.

func (*Span) SetTag

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

Adds a tag to the span.

func (*Span) Tracer

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

Provides access to the Tracer that created this Span.

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

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

FindAllSpans returns all the spans with the defined operation name.

func (*Tracer) FindSpan

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

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

func (t *Tracer) Reset(traceContent string)

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

func (*Tracer) StartSpan

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

Jump to

Keyboard shortcuts

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