tracing

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package tracing wires OpenTelemetry distributed tracing for the LLM proxy.

ENABLE_TRACING and TRACING_ENDPOINT have been parsed into the gateway config for some time without anything behind them; this package is what they now drive. When tracing is disabled the global provider stays OpenTelemetry's no-op implementation, so span creation on the request path costs nothing and callers never need to branch on whether it is on.

Index

Constants

View Source
const TracerName = "aistudio/proxy"

TracerName is the instrumentation scope for every span this package's callers create.

Variables

This section is empty.

Functions

func ExtractIncoming

func ExtractIncoming(ctx context.Context, header map[string][]string) context.Context

ExtractIncoming returns a context carrying the trace parent from the inbound request headers, so gateway spans become children of the caller's trace rather than starting a disconnected one.

func InjectOutgoing

func InjectOutgoing(ctx context.Context, header map[string][]string)

InjectOutgoing writes the current trace context into the upstream request headers so the provider (or an in-cluster model server) can continue the trace.

func Tracer

func Tracer() trace.Tracer

Tracer returns the tracer every proxy span is created from.

func Use

func Use(provider trace.TracerProvider, propagator propagation.TextMapPropagator)

Use makes Studio create spans from provider and carry trace context with propagator instead of the OpenTelemetry globals, which belong to an embedding host. A nil argument keeps the corresponding global.

Types

type Config

type Config struct {
	Enabled bool
	// Endpoint is the OTLP collector address. A bare "host:port" is assumed to
	// be an insecure gRPC endpoint; an http:// or https:// URL sets the
	// transport security from the scheme.
	Endpoint       string
	ServiceName    string
	ServiceVersion string
}

Config describes how to export spans. It mirrors the existing ObservabilityConfig fields rather than introducing new ones.

type Shutdown

type Shutdown func(context.Context) error

Shutdown flushes and stops the exporter. It is always non-nil, so callers can defer it unconditionally.

func Init

func Init(ctx context.Context, cfg Config) (Shutdown, error)

Init installs a global TracerProvider and the W3C trace context propagator.

The propagator is installed even when tracing is disabled: it costs nothing, and it means an incoming traceparent is still carried through to the upstream provider so a caller's own tracing stays connected across the gateway.

Jump to

Keyboard shortcuts

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