tracing

package
v0.0.1-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 30 Imported by: 140

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TraceIDFromContext

func TraceIDFromContext(c context.Context, requireSampled bool) string

Types

type EventValue

type EventValue struct {
	Str string
	Num int64
}

type Opentelemetry

type Opentelemetry struct {
	Cfg *setting.Cfg
	// contains filtered or unexported fields
}

func (*Opentelemetry) Inject

func (ots *Opentelemetry) Inject(ctx context.Context, header http.Header, _ Span)

func (*Opentelemetry) Run

func (ots *Opentelemetry) Run(ctx context.Context) error

func (*Opentelemetry) Start

func (ots *Opentelemetry) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, Span)

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)

func (OpentelemetrySpan) SetStatus

func (s OpentelemetrySpan) SetStatus(code codes.Code, description string)

type Opentracing

type Opentracing struct {
	Cfg *setting.Cfg
	// contains filtered or unexported fields
}

func (*Opentracing) Inject

func (ts *Opentracing) Inject(ctx context.Context, header http.Header, span Span)

func (*Opentracing) Run

func (ts *Opentracing) Run(ctx context.Context) error

func (*Opentracing) Start

func (ts *Opentracing) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, Span)

type OpentracingSpan

type OpentracingSpan struct {
	// contains filtered or unexported fields
}

func (OpentracingSpan) AddEvents

func (s OpentracingSpan) AddEvents(keys []string, values []EventValue)

func (OpentracingSpan) End

func (s OpentracingSpan) End()

func (OpentracingSpan) RecordError

func (s OpentracingSpan) RecordError(err error, options ...trace.EventOption)

func (OpentracingSpan) SetAttributes

func (s OpentracingSpan) SetAttributes(key string, value interface{}, kv attribute.KeyValue)

func (OpentracingSpan) SetName

func (s OpentracingSpan) SetName(name string)

func (OpentracingSpan) SetStatus

func (s OpentracingSpan) SetStatus(code codes.Code, description 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)
}

Span defines a time range for an operation. This is equivalent to a single line in a flame graph.

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

func ProvideService

func ProvideService(cfg *setting.Cfg) (Tracer, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL