Documentation ¶
Index ¶
- func NewTracerProviderAndTracer(tracerName string) (*TracerProvider, *Tracer)
- type Span
- func (ms *Span) AddEvent(ctx context.Context, name string, attrs ...label.KeyValue)
- func (ms *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
- func (ms *Span) End(options ...oteltrace.SpanOption)
- func (ms *Span) IsRecording() bool
- func (ms *Span) RecordError(ctx context.Context, err error, opts ...oteltrace.ErrorOption)
- func (ms *Span) SetAttribute(key string, value interface{})
- func (ms *Span) SetAttributes(attributes ...label.KeyValue)
- func (ms *Span) SetName(name string)
- func (ms *Span) SetStatus(status codes.Code, msg string)
- func (ms *Span) SpanContext() oteltrace.SpanContext
- func (ms *Span) Tracer() oteltrace.Tracer
- type Tracer
- type TracerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTracerProviderAndTracer ¶ added in v0.12.0
func NewTracerProviderAndTracer(tracerName string) (*TracerProvider, *Tracer)
NewTracerProviderAndTracer return mock provider and tracer.
Types ¶
type Span ¶
type Span struct { Name string Attributes map[label.Key]label.Value Kind oteltrace.SpanKind Status codes.Code StatusMessage string ParentSpanID oteltrace.SpanID Links map[oteltrace.SpanContext][]label.KeyValue // contains filtered or unexported fields }
Span is a mock span used in association with Tracer for testing purpose only.
func (*Span) AddEventWithTimestamp ¶
func (ms *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
AddEvent does nothing.
func (*Span) End ¶
func (ms *Span) End(options ...oteltrace.SpanOption)
End puts the span into tracers ended spans.
func (*Span) IsRecording ¶
IsRecording always returns false for Span.
func (*Span) RecordError ¶
RecordError does nothing.
func (*Span) SetAttribute ¶
SetAttribute adds a single inferred attribute.
func (*Span) SetAttributes ¶
SetAttributes adds an attribute to Attributes member.
func (*Span) SpanContext ¶
func (ms *Span) SpanContext() oteltrace.SpanContext
SpanContext returns associated oteltrace.SpanContext.
If the receiver is nil it returns an empty oteltrace.SpanContext.
type Tracer ¶
type Tracer struct { // StartSpanID is used to initialize span ID. It is incremented // by one every time a new span is created. // // StartSpanID has to be aligned for 64-bit atomic operations. StartSpanID uint64 // Name of the tracer, received from the provider. Name string // Sampled specifies if the new span should be sampled or not. Sampled bool // OnSpanStarted is called every time a new span is started. OnSpanStarted func(span *Span) // contains filtered or unexported fields }
Tracer is a simple tracer used for testing purpose only. SpanID is atomically increased every time a new span is created.
func (*Tracer) EndedSpans ¶
func (*Tracer) Start ¶
func (mt *Tracer) Start(ctx context.Context, name string, o ...oteltrace.SpanOption) (context.Context, oteltrace.Span)
Start starts a new Span and puts it into the context.
The function generates a new random TraceID if either there is no parent SpanContext in context or the WithNewRoot option is passed to the function. Otherwise the function will take the TraceID from parent SpanContext.
Currently no other StartOption has any effect here.
type TracerProvider ¶ added in v0.12.0
type TracerProvider struct {
// contains filtered or unexported fields
}
func (*TracerProvider) Tracer ¶ added in v0.12.0
func (p *TracerProvider) Tracer(name string, _ ...oteltrace.TracerOption) oteltrace.Tracer