package trace
import "go.opentelemetry.io/otel/internal/trace"
Index ¶
- type MockSpan
- func (ms *MockSpan) AddEvent(ctx context.Context, name string, attrs ...kv.KeyValue)
- func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...kv.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 ...kv.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
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) AddEvent ¶
AddEvent does nothing.
func (*MockSpan) AddEventWithTimestamp ¶
func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...kv.KeyValue)
AddEvent does nothing.
func (*MockSpan) End ¶
End does nothing.
func (*MockSpan) IsRecording ¶
IsRecording always returns false for MockSpan.
func (*MockSpan) RecordError ¶
RecordError does nothing.
func (*MockSpan) SetAttribute ¶
SetAttribute does nothing.
func (*MockSpan) SetAttributes ¶
SetAttributes does nothing.
func (*MockSpan) SetError ¶
SetError does nothing.
func (*MockSpan) SetName ¶
SetName sets the span name.
func (*MockSpan) SetStatus ¶
SetStatus does nothing.
func (*MockSpan) SpanContext ¶
func (ms *MockSpan) SpanContext() apitrace.SpanContext
SpanContext returns associated kv.SpanContext. If the receiver is nil it returns an empty kv.SpanContext
func (*MockSpan) Tracer ¶
Tracer returns MockTracer implementation of Tracer.
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.
func (*MockTracer) WithSpan ¶
func (mt *MockTracer) WithSpan(ctx context.Context, name string, body func(context.Context) error, opts ...apitrace.StartOption) error
WithSpan does nothing except executing the body.
Source Files ¶
mock_span.go mock_tracer.go
Directories ¶
Path | Synopsis |
---|---|
internal/trace/parent |
- Version
- v0.9.0
- Published
- Jul 20, 2020
- Platform
- windows/amd64
- Imports
- 9 packages
- Last checked
- 1 hour ago –
Tools for package owners.