tracing

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tracing is the seam through which every outgoing client of the relay gets its OpenTelemetry providers.

The providers are values (Providers): the one who builds a client is handed them and passes them on, nothing is registered process-wide. The zero value is "not configured": a client built with it is built without any instrumentation wrapper, so tracing that is off costs nothing on the request path and in a poll pass.

The package holds what every family of clients shares: the start of a span that is a no-op when tracing is off (Providers.Start), and the instrumented HTTP transport (Providers.Transport) that redacts the URL it records. The families that have their own hook (the AWS SDK, go-redis, valkey-go) take the providers where they are built.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Providers

type Providers struct {
	// TracerProvider is the tracer provider of the relay; nil when tracing is off.
	TracerProvider trace.TracerProvider
	// MeterProvider is the meter provider of the relay; nil when there is none (no metric is recorded then).
	MeterProvider metric.MeterProvider
	// Propagator is the propagator of the relay (W3C trace context and baggage unless the operator chose others); it is
	// never nil when tracing is on.
	Propagator propagation.TextMapPropagator
}

Providers are the tracer provider, the meter provider and the propagator of the relay, given as values to whoever builds a client. The zero value means OpenTelemetry is not configured: Providers.Enabled is false, and a client is built without instrumentation. The fields are read by the code that hands them to a client library; when tracing is off they are nil and nothing reads them.

func New

New returns the providers of the relay. A nil tracer provider means that tracing is off, whatever the other arguments are. A nil propagator is W3C trace context and baggage.

func (Providers) Enabled

func (p Providers) Enabled() bool

Enabled reports whether tracing is configured: the clients are instrumented only then.

func (Providers) HTTPClient

func (p Providers) HTTPClient(timeout time.Duration, base http.RoundTripper) *http.Client

HTTPClient returns the HTTP client of the seam of the relay (httpclient.NewHTTPClient) with the instrumented transport of Providers.Transport: with tracing off it is the client of the seam as it is, with the transport unchanged. It lives here and not in the package of the seam, which stays free of the instrumentation packages (the WebAssembly build of the engine imports it).

func (Providers) Start

func (p Providers) Start(ctx context.Context, scope, name string, kind trace.SpanKind) (context.Context, Span)

Start starts a span of the given kind and name, a child of the span of ctx; scope names the instrumentation. When tracing is off it returns ctx and a span that does nothing, without allocating: the arguments are plain values for that reason.

func (Providers) Transport

func (p Providers) Transport(base http.RoundTripper) http.RoundTripper

Transport returns base wrapped with the stock OpenTelemetry HTTP client instrumentation (otelhttp.NewTransport), with the providers and the propagator of the relay: every request has a client span (name, kind and attributes are what otelhttp emits, following the HTTP semantic conventions) and carries the trace context and the baggage of its context as headers. The client metrics of otelhttp go to the meter provider when there is one, with the defaults of the library. When tracing is off it returns base itself. A nil base means http.DefaultTransport.

type Span

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

Span is a span that does nothing when tracing is off: the zero value is such a span, and calling it costs nothing and allocates nothing. It is the plain tracer API of OpenTelemetry for the spans that the relay starts itself (the parents of its background work), and nothing else.

func (Span) End

func (s Span) End()

End ends the span.

func (Span) IsRecording

func (s Span) IsRecording() bool

IsRecording reports whether the span records: callers build attributes only then.

func (Span) SetAttributes

func (s Span) SetAttributes(attrs ...attribute.KeyValue)

SetAttributes sets attributes on the span.

func (Span) SetStatus

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

SetStatus sets the status of the span.

func (Span) SpanContext

func (s Span) SpanContext() trace.SpanContext

SpanContext returns the span context of the span, the empty one when tracing is off.

Jump to

Keyboard shortcuts

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