tracing

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(span trace.Span, err error) error

Error sets the status to error and record the error as an exception in the provided span.

func Errorf

func Errorf(span trace.Span, format string, args ...any) error

Errorf wraps fmt.Errorf and also sets the status to error and record the error as an exception in the provided span.

func NewProfilingTracerProvider

func NewProfilingTracerProvider(tp tracerProvider) tracerProvider

NewProfilingTracerProvider creates a new tracer provider that annotates pprof samples with span_id label. This allows to establish a relationship between pprof profiles and reported tracing spans.

func TraceIDFromContext

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

Types

type Tracer

type Tracer interface {
	trace.Tracer

	// 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, trace.Span)
}

Tracer defines the service used to create new spans.

func InitializeTracerForTest

func InitializeTracerForTest(opts ...TracerForTestOption) Tracer

type TracerForTestOption

type TracerForTestOption func(tp *tracesdk.TracerProvider)

type TracingConfig

type TracingConfig struct {
	Address       string
	Propagation   string
	CustomAttribs []attribute.KeyValue

	Sampler          string
	SamplerParam     float64
	SamplerRemoteURL string

	ServiceName    string
	ServiceVersion string
	// contains filtered or unexported fields
}

func NewEmptyTracingConfig

func NewEmptyTracingConfig() *TracingConfig

func NewJaegerTracingConfig

func NewJaegerTracingConfig(address string, propagation string) (*TracingConfig, error)

func NewOTLPTracingConfig

func NewOTLPTracingConfig(address string, propagation string) (*TracingConfig, error)

func ParseTracingConfig

func ParseTracingConfig(cfg *setting.Cfg) (*TracingConfig, error)

func ProvideTracingConfig

func ProvideTracingConfig(cfg *setting.Cfg) (*TracingConfig, error)

func (TracingConfig) OTelExporterEnabled

func (tc TracingConfig) OTelExporterEnabled() bool

type TracingService

type TracingService struct {
	trace.Tracer
	// contains filtered or unexported fields
}

func ProvideService

func ProvideService(tracingCfg *TracingConfig) (*TracingService, error)

func (*TracingService) GetTracerProvider

func (ots *TracingService) GetTracerProvider() tracerProvider

func (*TracingService) Inject

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

func (*TracingService) OtelTracer

func (ots *TracingService) OtelTracer() trace.Tracer

func (*TracingService) Run

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

Jump to

Keyboard shortcuts

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