Skip to content

vllm.tracing

Modules:

Classes:

Functions:

SpanAttributes

Standard attributes for spans.

These are largely based on OpenTelemetry Semantic Conventions but are defined here as constants so they can be used by any backend or logger.

contains_trace_headers(headers)

Check if the provided headers dictionary contains trace context.

extract_trace_context(headers)

Extracts context from HTTP headers.

extract_trace_headers(headers)

Extract only trace-related headers from a larger header dictionary. Useful for logging or passing context to a non-OTel client.

instrument(obj=None, *, span_name='', attributes=None, record_exception=True)

Generic decorator to instrument functions.

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

Manually create a span with explicit timestamps.

Parameters:

  • span_name

    (str) –

    Name of the span to create.

  • start_time

    (int) –

    Start time in nanoseconds since epoch.

  • end_time

    (int | None, default: None ) –

    Optional end time in nanoseconds. If None, ends immediately.

  • attributes

    (dict[str, Any] | None, default: None ) –

    Optional dict of span attributes.

  • context

    (Any, default: None ) –

    Optional trace context (e.g., from extract_trace_context).

  • kind

    (Any, default: None ) –

    Optional SpanKind (e.g., SpanKind.SERVER).

is_tracing_available()

Returns True if any tracing backend (OTel, Profiler, etc.) is available. Use this to guard expensive tracing logic in the main code.