Documentation ¶
Index ¶
- func ContextWithSpan(ctx context.Context, span Span) context.Context
- func TraceIDFromContext(c context.Context, requireSampled bool) string
- type EventValue
- type FakeSpan
- func (t *FakeSpan) AddEvents(keys []string, values []EventValue)
- func (t *FakeSpan) End()
- func (t *FakeSpan) IsEnded() bool
- func (t *FakeSpan) RecordError(err error, options ...trace.EventOption)
- func (t *FakeSpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue)
- func (t *FakeSpan) SetName(name string)
- func (t *FakeSpan) SetStatus(code codes.Code, description string)
- type FakeTracer
- type Opentelemetry
- func (ots *Opentelemetry) Inject(ctx context.Context, header http.Header, _ Span)
- func (ots *Opentelemetry) OTelExporterEnabled() bool
- func (ots *Opentelemetry) Run(ctx context.Context) error
- func (ots *Opentelemetry) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, Span)
- type OpentelemetrySpan
- func (s OpentelemetrySpan) AddEvents(keys []string, values []EventValue)
- func (s OpentelemetrySpan) End()
- func (s OpentelemetrySpan) RecordError(err error, options ...trace.EventOption)
- func (s OpentelemetrySpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue)
- func (s OpentelemetrySpan) SetName(name string)
- func (s OpentelemetrySpan) SetStatus(code codes.Code, description string)
- type Span
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithSpan ¶
ContextWithSpan returns a new context.Context that holds a reference to the given span. If span is nil, a new context without an active span is returned. It is the equivalent of opentracing.ContextWithSpan and trace.ContextWithSpan.
Types ¶
type EventValue ¶
type FakeSpan ¶
type FakeSpan struct { Name string Attributes map[attribute.Key]attribute.Value StatusCode codes.Code Description string Err error Events map[string]EventValue // contains filtered or unexported fields }
func (*FakeSpan) AddEvents ¶
func (t *FakeSpan) AddEvents(keys []string, values []EventValue)
func (*FakeSpan) RecordError ¶
func (t *FakeSpan) RecordError(err error, options ...trace.EventOption)
func (*FakeSpan) SetAttributes ¶
type FakeTracer ¶
type FakeTracer struct {
Spans []*FakeSpan
}
func NewFakeTracer ¶
func NewFakeTracer() *FakeTracer
type Opentelemetry ¶
type Opentelemetry struct { Address string Propagation string Cfg *setting.Cfg // contains filtered or unexported fields }
func ParseSettings ¶
func ParseSettings(cfg *setting.Cfg) (*Opentelemetry, error)
func (*Opentelemetry) OTelExporterEnabled ¶
func (ots *Opentelemetry) OTelExporterEnabled() bool
type OpentelemetrySpan ¶
type OpentelemetrySpan struct {
// contains filtered or unexported fields
}
func (OpentelemetrySpan) AddEvents ¶
func (s OpentelemetrySpan) AddEvents(keys []string, values []EventValue)
func (OpentelemetrySpan) End ¶
func (s OpentelemetrySpan) End()
func (OpentelemetrySpan) RecordError ¶
func (s OpentelemetrySpan) RecordError(err error, options ...trace.EventOption)
func (OpentelemetrySpan) SetAttributes ¶
func (s OpentelemetrySpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue)
func (OpentelemetrySpan) SetName ¶
func (s OpentelemetrySpan) SetName(name string)
type Span ¶
type Span interface { // End finalizes the Span and adds its end timestamp. // Any further operations on the Span are not permitted after // End has been called. End() // SetAttributes adds additional data to a span. // SetAttributes repeats the key value pair with [string] and [any] // used for OpenTracing and [attribute.KeyValue] used for // OpenTelemetry. SetAttributes(key string, value interface{}, kv attribute.KeyValue) // SetName renames the span. SetName(name string) // SetStatus can be used to indicate whether the span was // successfully or unsuccessfully executed. // // Only useful for OpenTelemetry. SetStatus(code codes.Code, description string) // RecordError adds an error to the span. // // Only useful for OpenTelemetry. RecordError(err error, options ...trace.EventOption) // AddEvents adds additional data with a temporal dimension to the // span. // // Panics if the length of keys is shorter than the length of values. AddEvents(keys []string, values []EventValue) // contains filtered or unexported methods }
Span defines a time range for an operation. This is equivalent to a single line in a flame graph.
func SpanFromContext ¶
SpanFromContext returns the Span previously associated with ctx, or nil, if no such span could be found. It is the equivalent of opentracing.SpanFromContext and trace.SpanFromContext.
type Tracer ¶
type Tracer interface { // Run implements registry.BackgroundService. Run(context.Context) error // Start creates a new [Span] and places trace metadata on the // [context.Context] passed to the method. // Chose a low cardinality spanName and use [Span.SetAttributes] // or [Span.AddEvents] for high cardinality data. Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, Span) // Inject adds identifying information for the span to the // headers defined in [http.Header] map (this mutates http.Header). // // Implementation quirk: Where OpenTelemetry is used, the [Span] is // picked up from [context.Context] and for OpenTracing the // information passed as [Span] is preferred. // Both the context and span must be derived from the same call to // [Tracer.Start]. Inject(context.Context, http.Header, Span) }
Tracer defines the service used to create new spans.
func InitializeTracerForTest ¶
func InitializeTracerForTest() Tracer
Click to show internal directories.
Click to hide internal directories.