Documentation ¶
Index ¶
- func DefaultTracer() trace.Tracer
- type Event
- type Option
- type Span
- func (s *Span) AddEvent(name string, o ...trace.EventOption)
- func (s *Span) Attributes() map[attribute.Key]attribute.Value
- func (s *Span) End(opts ...trace.SpanEndOption)
- func (s *Span) EndTime() (time.Time, bool)
- func (s *Span) Ended() bool
- func (s *Span) Events() []Event
- func (s *Span) IsRecording() bool
- func (s *Span) Links() []trace.Link
- func (s *Span) Name() string
- func (s *Span) ParentSpanID() trace.SpanID
- func (s *Span) RecordError(err error, opts ...trace.EventOption)
- func (s *Span) SetAttributes(attrs ...attribute.KeyValue)
- func (s *Span) SetName(name string)
- func (s *Span) SetStatus(code codes.Code, msg string)
- func (s *Span) SpanContext() trace.SpanContext
- func (s *Span) SpanKind() trace.SpanKind
- func (s *Span) StartTime() time.Time
- func (s *Span) StatusCode() codes.Code
- func (s *Span) StatusMessage() string
- func (s *Span) Tracer() trace.Tracer
- func (s *Span) TracerProvider() trace.TracerProvider
- type SpanRecorder
- type TextMapCarrier
- func (c *TextMapCarrier) Get(key string) string
- func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool
- func (c *TextMapCarrier) GotN(t *testing.T, n int) bool
- func (c *TextMapCarrier) Keys() []string
- func (c *TextMapCarrier) Reset()
- func (c *TextMapCarrier) Set(key, value string)
- func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool
- func (c *TextMapCarrier) SetN(t *testing.T, n int) bool
- type TextMapPropagator
- func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
- func (p *TextMapPropagator) ExtractedN(t *testing.T, ctx context.Context, n int) bool
- func (p *TextMapPropagator) Fields() []string
- func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
- func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool
- type Tracer
- type TracerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTracer ¶
DefaulTracer returns a default tracer for testing purposes.
Types ¶
type Option ¶
type Option interface { Apply(*config) // contains filtered or unexported methods }
Option applies an option to a config.
func WithSpanContextFunc ¶
func WithSpanContextFunc(f func(context.Context) trace.SpanContext) Option
WithSpanContextFunc sets the SpanContextFunc used to generate a new Spans context from a parent SpanContext.
func WithSpanRecorder ¶
func WithSpanRecorder(sr *SpanRecorder) Option
WithSpanRecorder sets the SpanRecorder to use with the TracerProvider for testing.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span is an OpenTelemetry Span used for testing.
func (*Span) AddEvent ¶
func (s *Span) AddEvent(name string, o ...trace.EventOption)
AddEvent adds an event to s.
func (*Span) Attributes ¶
Attributes returns the attributes set on s, either at or after creation time. If the same attribute key was set multiple times, the last call will be used. Attributes cannot be changed after End has been called on s.
func (*Span) End ¶
func (s *Span) End(opts ...trace.SpanEndOption)
End ends s. If the Tracer that created s was configured with a SpanRecorder, that recorder's OnEnd method is called as the final part of this method.
func (*Span) EndTime ¶
EndTime returns the time at which s was ended if at has been ended, or false otherwise. If the span has been ended, the returned time will be the wall-clock time unless a specific end time was provided.
func (*Span) Ended ¶
Ended returns whether s has been ended, i.e. whether End has been called at least once on s.
func (*Span) Events ¶
Events returns the events set on s. Events cannot be changed after End has been called on s.
func (*Span) IsRecording ¶
IsRecording returns the recording state of s.
func (*Span) Links ¶
Links returns the links set on s at creation time. If multiple links for the same SpanContext were set, the last link will be used.
func (*Span) Name ¶
Name returns the name most recently set on s, either at or after creation time. It cannot be change after End has been called on s.
func (*Span) ParentSpanID ¶
ParentSpanID returns the SpanID of the parent Span. If s is a root Span, and therefore does not have a parent, the returned SpanID will be invalid (i.e., it will contain all zeroes).
func (*Span) RecordError ¶
func (s *Span) RecordError(err error, opts ...trace.EventOption)
RecordError records an error as an exception Span event.
func (*Span) SetAttributes ¶
SetAttributes sets attrs as attributes of s.
func (*Span) SpanContext ¶
func (s *Span) SpanContext() trace.SpanContext
SpanContext returns the SpanContext of s.
func (*Span) StartTime ¶
StartTime returns the time at which s was started. This will be the wall-clock time unless a specific start time was provided.
func (*Span) StatusCode ¶
StatusCode returns the code of the status most recently set on s, or codes.OK if no status has been explicitly set. It cannot be changed after End has been called on s.
func (*Span) StatusMessage ¶
StatusMessage returns the status message most recently set on s or the empty string if no status message was set.
func (*Span) TracerProvider ¶
func (s *Span) TracerProvider() trace.TracerProvider
type SpanRecorder ¶
type SpanRecorder struct {
// contains filtered or unexported fields
}
SpanRecorder performs operations to record a span as it starts and ends. It is designed to be concurrent safe and can by used by multiple goroutines.
func (*SpanRecorder) Completed ¶
func (ssr *SpanRecorder) Completed() []*Span
Completed returns a copy of all ended Spans in the order they were ended.
func (*SpanRecorder) OnEnd ¶
func (ssr *SpanRecorder) OnEnd(span *Span)
OnEnd records span as completed.
func (*SpanRecorder) OnStart ¶
func (ssr *SpanRecorder) OnStart(span *Span)
OnStart records span as started.
func (*SpanRecorder) Started ¶
func (ssr *SpanRecorder) Started() []*Span
Started returns a copy of all started Spans in the order they were started.
type TextMapCarrier ¶
type TextMapCarrier struct {
// contains filtered or unexported fields
}
TextMapCarrier provides a testing storage medium to for a TextMapPropagator. It records all the operations it performs.
func NewTextMapCarrier ¶
func NewTextMapCarrier(data map[string]string) *TextMapCarrier
NewTextMapCarrier returns a new *TextMapCarrier populated with data.
func (*TextMapCarrier) Get ¶
func (c *TextMapCarrier) Get(key string) string
Get returns the value associated with the passed key.
func (*TextMapCarrier) GotKey ¶
func (c *TextMapCarrier) GotKey(t *testing.T, key string) bool
GotKey tests if c.Get has been called for key.
func (*TextMapCarrier) GotN ¶
func (c *TextMapCarrier) GotN(t *testing.T, n int) bool
GotN tests if n calls to c.Get have been made.
func (*TextMapCarrier) Keys ¶
func (c *TextMapCarrier) Keys() []string
Keys returns the keys for which this carrier has a value.
func (*TextMapCarrier) Reset ¶
func (c *TextMapCarrier) Reset()
Reset zeros out the internal state recording of c.
func (*TextMapCarrier) Set ¶
func (c *TextMapCarrier) Set(key, value string)
Set stores the key-value pair.
func (*TextMapCarrier) SetKeyValue ¶
func (c *TextMapCarrier) SetKeyValue(t *testing.T, key, value string) bool
SetKeyValue tests if c.Set has been called for the key-value pair.
type TextMapPropagator ¶
type TextMapPropagator struct { Name string // contains filtered or unexported fields }
func NewTextMapPropagator ¶
func NewTextMapPropagator(name string) *TextMapPropagator
func (*TextMapPropagator) Extract ¶
func (p *TextMapPropagator) Extract(ctx context.Context, carrier propagation.TextMapCarrier) context.Context
Extract reads cross-cutting concerns for p from the carrier into a Context.
func (*TextMapPropagator) ExtractedN ¶
ExtractedN tests if p has made n extractions from the lineage of ctx. nolint (context is not first arg)
func (*TextMapPropagator) Fields ¶
func (p *TextMapPropagator) Fields() []string
Fields returns p.Name as the key who's value is set with Inject.
func (*TextMapPropagator) Inject ¶
func (p *TextMapPropagator) Inject(ctx context.Context, carrier propagation.TextMapCarrier)
Inject set cross-cutting concerns for p from the Context into the carrier.
func (*TextMapPropagator) InjectedN ¶
func (p *TextMapPropagator) InjectedN(t *testing.T, carrier *TextMapCarrier, n int) bool
InjectedN tests if p has made n injections to carrier.
type Tracer ¶
type Tracer struct { // Name is the instrumentation name. Name string // Version is the instrumentation version. Version string // contains filtered or unexported fields }
Tracer is an OpenTelemetry Tracer implementation used for testing.
type TracerProvider ¶
type TracerProvider struct {
// contains filtered or unexported fields
}
TracerProvider is a testing TracerProvider. It is an functioning implementation of an OpenTelemetry TracerProvider and can be configured with a SpanRecorder that it configure all Tracers it creates to record their Spans with.
func NewTracerProvider ¶
func NewTracerProvider(options ...Option) *TracerProvider
NewTracerProvider returns a *TracerProvider configured with options.
func (*TracerProvider) Tracer ¶
func (p *TracerProvider) Tracer(instName string, opts ...trace.TracerOption) trace.Tracer
Tracer returns an OpenTelemetry Tracer used for testing.