Documentation ¶
Index ¶
- type MockSpan
- func (ms *MockSpan) AddEvent(ctx context.Context, name string, attrs ...label.KeyValue)
- func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
- func (ms *MockSpan) End(options ...apitrace.EndOption)
- func (ms *MockSpan) IsRecording() bool
- func (ms *MockSpan) RecordError(ctx context.Context, err error, opts ...apitrace.ErrorOption)
- func (ms *MockSpan) SetAttribute(k string, v interface{})
- func (ms *MockSpan) SetAttributes(attributes ...label.KeyValue)
- func (ms *MockSpan) SetError(v bool)
- func (ms *MockSpan) SetName(name string)
- func (ms *MockSpan) SetStatus(status codes.Code, msg string)
- func (ms *MockSpan) SpanContext() apitrace.SpanContext
- func (ms *MockSpan) Tracer() apitrace.Tracer
- type MockTracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockSpan ¶
type MockSpan struct { Name string Status codes.Code StatusMsg string // contains filtered or unexported fields }
MockSpan is a mock span used in association with MockTracer for testing purpose only.
func (*MockSpan) AddEventWithTimestamp ¶
func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
AddEvent does nothing.
func (*MockSpan) IsRecording ¶
IsRecording always returns false for MockSpan.
func (*MockSpan) RecordError ¶ added in v0.2.3
RecordError does nothing.
func (*MockSpan) SetAttribute ¶
SetAttribute does nothing.
func (*MockSpan) SetAttributes ¶
SetAttributes does nothing.
func (*MockSpan) SpanContext ¶
func (ms *MockSpan) SpanContext() apitrace.SpanContext
SpanContext returns associated label.SpanContext. If the receiver is nil it returns an empty label.SpanContext
type MockTracer ¶
type MockTracer struct { // StartSpanID is used to initialize spanId. It is incremented by one // every time a new span is created. // // StartSpanID has to be aligned for 64-bit atomic operations. StartSpanID *uint64 // Sampled specifies if the new span should be sampled or not. Sampled bool // OnSpanStarted is called every time a new trace span is started OnSpanStarted func(span *MockSpan) }
MockTracer is a simple tracer used for testing purpose only. It only supports ChildOf option. SpanId is atomically increased every time a new span is created.
func (*MockTracer) Start ¶
func (mt *MockTracer) Start(ctx context.Context, name string, o ...apitrace.StartOption) (context.Context, apitrace.Span)
Start starts a MockSpan. It creates a new Span based on Parent SpanContext option. TracdID is used from Parent Span Context and SpanID is assigned. If Parent SpanContext option is not specified then random TraceID is used. No other options are supported.