Documentation ¶
Index ¶
- type Extractor
- type Injector
- type MockKeyValue
- func (m *MockKeyValue) EmitBool(key string, value bool)
- func (m *MockKeyValue) EmitFloat32(key string, value float32)
- func (m *MockKeyValue) EmitFloat64(key string, value float64)
- func (m *MockKeyValue) EmitInt(key string, value int)
- func (m *MockKeyValue) EmitInt32(key string, value int32)
- func (m *MockKeyValue) EmitInt64(key string, value int64)
- func (m *MockKeyValue) EmitLazyLogger(value log.LazyLogger)
- func (m *MockKeyValue) EmitObject(key string, value interface{})
- func (m *MockKeyValue) EmitString(key, value string)
- func (m *MockKeyValue) EmitUint32(key string, value uint32)
- func (m *MockKeyValue) EmitUint64(key string, value uint64)
- type MockLogRecord
- 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) LogFields(fields ...log.Field)
- func (s *MockSpan) LogKV(keyValues ...interface{})
- func (s *MockSpan) Logs() []MockLogRecord
- 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 MockKeyValue ¶
type MockKeyValue struct { Key string // All MockLogRecord values are coerced to strings via fmt.Sprint(), though // we retain their type separately. ValueKind reflect.Kind ValueString string }
MockKeyValue represents a single key:value pair.
func (*MockKeyValue) EmitBool ¶
func (m *MockKeyValue) EmitBool(key string, value bool)
EmitBool belongs to the log.Encoder interface
func (*MockKeyValue) EmitFloat32 ¶
func (m *MockKeyValue) EmitFloat32(key string, value float32)
EmitFloat32 belongs to the log.Encoder interface
func (*MockKeyValue) EmitFloat64 ¶
func (m *MockKeyValue) EmitFloat64(key string, value float64)
EmitFloat64 belongs to the log.Encoder interface
func (*MockKeyValue) EmitInt ¶
func (m *MockKeyValue) EmitInt(key string, value int)
EmitInt belongs to the log.Encoder interface
func (*MockKeyValue) EmitInt32 ¶
func (m *MockKeyValue) EmitInt32(key string, value int32)
EmitInt32 belongs to the log.Encoder interface
func (*MockKeyValue) EmitInt64 ¶
func (m *MockKeyValue) EmitInt64(key string, value int64)
EmitInt64 belongs to the log.Encoder interface
func (*MockKeyValue) EmitLazyLogger ¶
func (m *MockKeyValue) EmitLazyLogger(value log.LazyLogger)
EmitLazyLogger belongs to the log.Encoder interface
func (*MockKeyValue) EmitObject ¶
func (m *MockKeyValue) EmitObject(key string, value interface{})
EmitObject belongs to the log.Encoder interface
func (*MockKeyValue) EmitString ¶
func (m *MockKeyValue) EmitString(key, value string)
EmitString belongs to the log.Encoder interface
func (*MockKeyValue) EmitUint32 ¶
func (m *MockKeyValue) EmitUint32(key string, value uint32)
EmitUint32 belongs to the log.Encoder interface
func (*MockKeyValue) EmitUint64 ¶
func (m *MockKeyValue) EmitUint64(key string, value uint64)
EmitUint64 belongs to the log.Encoder interface
type MockLogRecord ¶
type MockLogRecord struct { Timestamp time.Time Fields []MockKeyValue }
MockLogRecord represents data logged to a Span via Span.LogFields or Span.LogKV.
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) LogEvent ¶
LogEvent belongs to the Span interface
func (*MockSpan) LogEventWithPayload ¶
LogEventWithPayload belongs to the Span interface
func (*MockSpan) LogFields ¶
LogFields belongs to the Span interface
func (*MockSpan) LogKV ¶
func (s *MockSpan) LogKV(keyValues ...interface{})
LogKV belongs to the Span interface.
This implementations coerces all "values" to strings, though that is not something all implementations need to do. Indeed, a motivated person can and probably should have this do a typed switch on the values.
func (*MockSpan) Logs ¶
func (s *MockSpan) Logs() []MockLogRecord
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
func (*MockSpan) SetTag ¶
SetTag belongs to the Span interface
func (*MockSpan) String ¶
String allows printing span for debugging
func (*MockSpan) Tags ¶
Tags returns a copy of tags accumulated by the span so far
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