Skip to content

vllm.tracing.otel

Functions:

_get_smart_context()

Determines the parent context. 1. If a Span is already active in this process, use it. 2. If not, extract from os.environ, handling the case-sensitivity mismatch.

extract_trace_context(headers)

Extracts context from HTTP headers.

init_otel_tracer(instrumenting_module_name, otlp_traces_endpoint, extra_attributes=None)

Initializes the OpenTelemetry tracer provider.

init_otel_worker_tracer(instrumenting_module_name, process_kind, process_name)

Backend-specific initialization for OpenTelemetry in a worker process.

instrument_otel(func, span_name, attributes, record_exception)

Internal wrapper logic for sync and async functions.

manual_instrument_otel(span_name, start_time, end_time=None, attributes=None, context=None, kind=None)

Manually create and end a span with explicit timestamps.

propagate_trace_to_env()

Temporarily injects the current OTel context into os.environ. This ensures that any subprocesses (like vLLM workers) spawned within this context inherit the correct traceparent.