Skip to content

Fix llm_request trace context propagation#38678

Open
will-deines wants to merge 3 commits intovllm-project:mainfrom
will-deines:fix/llm-request-tracing-context
Open

Fix llm_request trace context propagation#38678
will-deines wants to merge 3 commits intovllm-project:mainfrom
will-deines:fix/llm-request-tracing-context

Conversation

@will-deines
Copy link
Copy Markdown

Summary

  • preserve request-scoped trace context for llm_request instead of falling back to ambient process environment state during final span emission
  • normalize propagated trace headers case-insensitively and carry them explicitly through serving and engine request processing
  • add regression coverage asserting llm_request stays in the parent distributed trace while receiving its own unique span id

Duplicate-work check

Testing

  • ./.venv/bin/python -m pytest tests/tracing/test_otel.py -v -s (5 passed)
  • PRE_COMMIT_HOME=/tmp/pre-commit-vllm-upstream-tracing XDG_CACHE_HOME=/tmp/xdg-cache-vllm-upstream-tracing NPM_CONFIG_CACHE=/tmp/npm-cache-vllm-upstream-tracing ./.venv/bin/pre-commit run --files vllm/tracing/utils.py vllm/tracing/otel.py vllm/tracing/__init__.py vllm/entrypoints/openai/engine/serving.py vllm/entrypoints/pooling/base/serving.py vllm/v1/engine/input_processor.py vllm/v1/engine/output_processor.py tests/tracing/test_otel.py (passed)

AI assistance

AI assistance was used to draft and implement this change. The submitter reviewed the final diff and validated the tests above.

Assisted-by: OpenAI Codex

Signed-off-by: Will Deines <will@garr.io>
Assisted-by: OpenAI Codex

Signed-off-by: Will Deines <will@garr.io>
Co-authored-by: OpenAI Codex

Signed-off-by: Will Deines <will@garr.io>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances OpenTelemetry tracing by improving trace context propagation and header handling. Key changes include making trace header extraction case-insensitive, adding a mechanism to retrieve trace headers from the current OTel context when request headers are missing, and introducing a use_environment_context flag to control fallback behavior to environment variables. Additionally, trace headers are now normalized in the V1 engine input processor, and comprehensive tests have been added to verify these improvements. I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants