Documentation
¶
Index ¶
- type Extractor
- type Injector
- type MockSpan
- func (s *MockSpan) BaggageItem(key string) string
- func (s *MockSpan) Context() opentracing.SpanContext
- func (s *MockSpan) Finish()
- func (s *MockSpan) FinishWithOptions(opts opentracing.FinishOptions)
- func (s *MockSpan) Log(data opentracing.LogData)
- func (s *MockSpan) LogEvent(event string)
- func (s *MockSpan) LogEventWithPayload(event string, payload interface{})
- func (s *MockSpan) Logs() []opentracing.LogData
- func (s *MockSpan) SetBaggageItem(key, val string) opentracing.Span
- func (s *MockSpan) SetOperationName(operationName string) opentracing.Span
- func (s *MockSpan) SetTag(key string, value interface{}) opentracing.Span
- func (s *MockSpan) String() string
- func (s *MockSpan) Tag(k string) interface{}
- func (s *MockSpan) Tags() map[string]interface{}
- func (s *MockSpan) Tracer() opentracing.Tracer
- type MockSpanContext
- type MockTracer
- func (t *MockTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
- func (t *MockTracer) FinishedSpans() []*MockSpan
- func (t *MockTracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error
- func (t *MockTracer) RegisterExtractor(format interface{}, extractor Extractor)
- func (t *MockTracer) RegisterInjector(format interface{}, injector Injector)
- func (t *MockTracer) Reset()
- func (t *MockTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
- type TextMapPropagator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor interface { // Extract decodes a SpanContext instance from the given `carrier`, // or (nil, opentracing.ErrSpanContextNotFound) if no context could // be found in the `carrier`. Extract(carrier interface{}) (MockSpanContext, error) }
Extractor is responsible for extracting SpanContext instances from a format-specific "carrier" object. Typically the extraction will take place on the server side of an RPC boundary, but message queues and other IPC mechanisms are also reasonable places to use an Extractor.
type Injector ¶
type Injector interface { // Inject takes `SpanContext` and injects it into `carrier`. The actual type // of `carrier` depends on the `format` passed to `Tracer.Inject()`. // // Implementations may return opentracing.ErrInvalidCarrier or any other // implementation-specific error if injection fails. Inject(ctx MockSpanContext, carrier interface{}) error }
Injector is responsible for injecting SpanContext instances in a manner suitable for propagation via a format-specific "carrier" object. Typically the injection will take place across an RPC boundary, but message queues and other IPC mechanisms are also reasonable places to use an Injector.
type MockSpan ¶
type MockSpan struct { sync.RWMutex ParentID int OperationName string StartTime time.Time FinishTime time.Time // All of the below are protected by the embedded RWMutex. SpanContext MockSpanContext // contains filtered or unexported fields }
MockSpan is an opentracing.Span implementation that exports its internal state for testing purposes.
func (*MockSpan) BaggageItem ¶
BaggageItem belongs to the Span interface
func (*MockSpan) Context ¶
func (s *MockSpan) Context() opentracing.SpanContext
Context belongs to the Span interface
func (*MockSpan) FinishWithOptions ¶
func (s *MockSpan) FinishWithOptions(opts opentracing.FinishOptions)
FinishWithOptions belongs to the Span interface
func (*MockSpan) Log ¶
func (s *MockSpan) Log(data opentracing.LogData)
Log belongs to the Span interface
func (*MockSpan) LogEventWithPayload ¶
LogEventWithPayload belongs to the Span interface
func (*MockSpan) Logs ¶
func (s *MockSpan) Logs() []opentracing.LogData
Logs returns a copy of logs accumulated in the span so far
func (*MockSpan) SetBaggageItem ¶
SetBaggageItem belongs to the Span interface
func (*MockSpan) SetOperationName ¶
SetOperationName belongs to the Span interface
type MockSpanContext ¶
MockSpanContext is an opentracing.SpanContext implementation.
It is entirely unsuitable for production use, but appropriate for tests that want to verify tracing behavior in other frameworks/applications.
By default all spans have Sampled=true flag, unless {"sampling.priority": 0} tag is set.
func (MockSpanContext) ForeachBaggageItem ¶
func (c MockSpanContext) ForeachBaggageItem(handler func(k, v string) bool)
ForeachBaggageItem belongs to the SpanContext interface
func (MockSpanContext) WithBaggageItem ¶
func (c MockSpanContext) WithBaggageItem(key, value string) MockSpanContext
WithBaggageItem creates a new context with an extra baggage item.
type MockTracer ¶
MockTracer is only intended for testing OpenTracing instrumentation.
It is entirely unsuitable for production use, but appropriate for tests that want to verify tracing behavior in other frameworks/applications.
func New ¶
func New() *MockTracer
New returns a MockTracer opentracing.Tracer implementation that's intended to facilitate tests of OpenTracing instrumentation.
func (*MockTracer) Extract ¶
func (t *MockTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error)
Extract belongs to the Tracer interface.
func (*MockTracer) FinishedSpans ¶
func (t *MockTracer) FinishedSpans() []*MockSpan
FinishedSpans returns all spans that have been Finish()'ed since the MockTracer was constructed or since the last call to its Reset() method.
func (*MockTracer) Inject ¶
func (t *MockTracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error
Inject belongs to the Tracer interface.
func (*MockTracer) RegisterExtractor ¶
func (t *MockTracer) RegisterExtractor(format interface{}, extractor Extractor)
RegisterExtractor registers extractor for given format
func (*MockTracer) RegisterInjector ¶
func (t *MockTracer) RegisterInjector(format interface{}, injector Injector)
RegisterInjector registers injector for given format
func (*MockTracer) Reset ¶
func (t *MockTracer) Reset()
Reset clears the internally accumulated finished spans. Note that any extant MockSpans will still append to finishedSpans when they Finish(), even after a call to Reset().
func (*MockTracer) StartSpan ¶
func (t *MockTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span
StartSpan belongs to the Tracer interface.
type TextMapPropagator ¶
type TextMapPropagator struct {
HTTPHeaders bool
}
TextMapPropagator implements Injector/Extractor for TextMap and HTTPHeaders formats.
func (*TextMapPropagator) Extract ¶
func (t *TextMapPropagator) Extract(carrier interface{}) (MockSpanContext, error)
Extract implements the Extractor interface
func (*TextMapPropagator) Inject ¶
func (t *TextMapPropagator) Inject(spanContext MockSpanContext, carrier interface{}) error
Inject implements the Injector interface