vllm.tracing ¶
Modules:
| Name | Description |
|---|---|
otel | |
utils | |
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.
Source code in vllm/tracing/utils.py
contains_trace_headers ¶
extract_trace_context ¶
Extracts context from HTTP headers.
extract_trace_headers ¶
Extract only trace-related headers from a larger header dictionary. Useful for logging or passing context to a non-OTel client.
Source code in vllm/tracing/utils.py
instrument ¶
instrument(
obj: Callable | None = None,
*,
span_name: str = "",
attributes: dict[str, str] | None = None,
record_exception: bool = True,
)
Generic decorator to instrument functions.
Source code in vllm/tracing/__init__.py
instrument_manual ¶
instrument_manual(
span_name: str,
start_time: int,
end_time: int | None = None,
attributes: dict[str, Any] | None = None,
context: Any = None,
kind: Any = None,
)
Manually create a span with explicit timestamps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
span_name | str | Name of the span to create. | required |
start_time | int | Start time in nanoseconds since epoch. | required |
end_time | int | None | Optional end time in nanoseconds. If None, ends immediately. | None |
attributes | dict[str, Any] | None | Optional dict of span attributes. | None |
context | Any | Optional trace context (e.g., from extract_trace_context). | None |
kind | Any | Optional SpanKind (e.g., SpanKind.SERVER). | None |
Source code in vllm/tracing/__init__.py
is_tracing_available ¶
is_tracing_available() -> bool
Returns True if any tracing backend (OTel, Profiler, etc.) is available. Use this to guard expensive tracing logic in the main code.