Skip to content

feat(telemetry): add execution traces and upstream context propagation - #349

Merged
haoshan98 merged 7 commits into
vllm-project:mainfrom
Zheng-Lu:feat/339-execution-traces
Sep 25, 2026
Merged

haoshan98 merged 7 commits into
vllm-project:mainfrom
Zheng-Lu:feat/339-execution-traces

Conversation

@Zheng-Lu

Copy link
Copy Markdown
Contributor

Summary

Closes #339. Implements execution-level tracing for phase 2 of #279 on top of the existing OpenTelemetry bridge.

  • Add agentic.execute for Responses and Messages with separate, bounded execution and delivery outcomes, including streaming failures, cancellation, and disconnects.
  • Add rehydration, inference-round, gateway tool execution, compaction, and persistence spans. Keep stage parentage across spawned tasks and stream polling. Inject W3C context from the http.client.request span in the shared inference transport; record only method, host, port, status, and bounded failure categories.
  • Add a WebSocket session span and one execution trace per admitted response.create, including generate:false, queue wait, and cancellation of queued work. Design choice: each execution is a new trace linked to the session, not its child.
  • Add thin execution spans for raw Responses and Messages proxy routes while preserving payload bytes. Design choice: outbound proxy trace headers use the gateway execution context rather than forwarding the caller's parent unchanged. Proxy outcomes describe transport, not semantic model execution.
  • Use the agentic.* namespace, enforce per-span attribute allow-lists and sensitive-value checks, and document propagation, sampling, privacy, and transport boundaries. Core depends only on the OpenTelemetry API/bridge, not SDKs or exporters. Small responsibility-preserving file splits keep the Rust file-size policy satisfied; ingestion, relay semantics, and channel bounds are unchanged.

Test Plan

All required gates passed before each step commit. Final validation:

cargo fmt -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo test -p agentic-server-core
RUST_TEST_THREADS=1 cargo test -p agentic-server
uvx pre-commit run --all-files
  • Core execution-trace suite: 15 passing tests, including a replayed two-round streaming cassette with exact span-tree/upstream-parent assertions, HTTP failure sanitization, streamed stage parentage under unrelated consumer tasks, all three compaction triggers, all rehydration sources, and both persistence destinations. Existing cassettes were reused without modification.
  • Server execution-trace suite: 4 passing tests through the production router, covering linked WebSocket roots, pipelining and queue wait, generate:false, invalid frames, active/queued disconnects, and both proxy APIs with raw JSON, declared-length/chunked/empty streams, HTTP rejection, disconnect, and body-read failures. The collector end-to-end test also checks the new proxy execution span.
  • Negative controls: every newly added stage, WebSocket, proxy, and compaction test failed with its source changes stashed, then passed after restoration. Existing streaming-parentage tests also failed when their stream/task instrumentation was temporarily removed. The privacy scanner rejected both a deliberately undeclared attribute and sensitive fixture text placed under an allowed key; both probes were removed.
  • An initial concurrent server run encountered an apparent ephemeral-port reuse race in existing Messages tests. All 15 Messages tests passed in isolation with serial execution, and the complete server suite passed serially. No unrelated fixture changes were made.
  • All pre-commit hooks were rerun successfully immediately before opening this PR. HANDOFF-339.md, pr_info.txt, and docs/rfcs/ are excluded from the commits.

First step of vllm-project#339 (phase 2 of vllm-project#279): one `agentic.execute` span per
request, under the phase 1 `http.server.request` span, for both the
Responses and Messages APIs, streaming or not.

- `executor::telemetry` holds the span guard and the closed outcome
  enums. `ExecutionSpan` finalizes exactly once on drop, so a dropped
  stream or an aborted task is recorded as `cancelled`/`disconnected`
  rather than lost. `FailureCategory` is derived exhaustively from the
  `ExecutorError` variant, never from its message, and becomes the
  bounded `error.type`. Execution and delivery are recorded separately:
  an SSE `error` frame under HTTP 200 is `failed`/`delivered`; a Messages
  upstream error body relayed verbatim is `failed`/`upstream_error` even
  though the handler never sees an `Err`.
- `InstrumentedStream` enters the span on every poll, the stream
  equivalent of `tracing::Instrument`, so work done while streaming
  (later rounds, persistence) stays attributed to the request. The
  spawned executor task is instrumented with the same span.
- The core library still depends on `tracing` only; a test guards that
  no SDK, exporter, or subscriber can be added to its normal
  dependencies.
- `ExecuteRequest` moves to `engine/execute.rs` and the buffered-block
  types to `messages_stream/blocks.rs` to keep both parents inside the
  file-size policy; pure moves.

Tests replay a mock upstream through the real executor into an
in-memory exporter. The harness installs one global subscriber per test
binary and isolates tests by trace id: `sqlx-sqlite` closes spans on its
worker thread, where a scoped `with_subscriber` dispatcher is not in
effect, so a scoped harness leaked parent spans.

Signed-off-by: Zheng Lu <[email protected]>
Enforce shared per-span attribute contracts across executor and transport traces. Cover compaction triggers, restored state, and persistence destinations without exporting request content. Document upstream propagation, WebSocket links, proxy outcomes, and sampling boundaries.

Validation: cargo fmt -- --check; cargo clippy --workspace --all-targets -- -D warnings; cargo test -p agentic-server-core; RUST_TEST_THREADS=1 cargo test -p agentic-server; uvx pre-commit run --all-files. The new compaction test fails with source changes stashed, and deliberate attribute-key and sensitive-value probes fail the scanner.
Signed-off-by: Zheng Lu <[email protected]>

@haoshan98 haoshan98 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for supporting the telemetry tracing, lgtm!

@haoshan98

Copy link
Copy Markdown
Collaborator

Thanks for supporting the telemetry tracing, lgtm!

Kindly help to resolve the merge conflict.

Resolve the compaction overlap while preserving prompt_cache_key forwarding and bounded compaction trigger spans. Update trace test request construction for the new field and keep large integration test futures off the stack.

Signed-off-by: Zheng Lu <[email protected]>
@Zheng-Lu

Zheng-Lu commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@haoshan98

Conflicts resolved now.

About the ci failed job: Its cargo build step failed while Rustup was repairing a partially installed Rust 1.98.0 toolchain (detected conflict: 'bin/cargo-clippy'). The same build passed in the Codex matrix job and locally, so this appears to be runner-specific. I don’t have permission to rerun this single job myself.

@haoshan98
haoshan98 merged commit 9a9b052 into vllm-project:main Sep 25, 2026
22 of 23 checks passed
@haoshan98

Copy link
Copy Markdown
Collaborator

@haoshan98

Conflicts resolved now.

About the ci failed job: Its cargo build step failed while Rustup was repairing a partially installed Rust 1.98.0 toolchain (detected conflict: 'bin/cargo-clippy'). The same build passed in the Codex matrix job and locally, so this appears to be runner-specific. I don’t have permission to rerun this single job myself.

Rerun succeeded, merged.

haoshan98 added a commit that referenced this pull request Sep 30, 2026
## Summary

Several user-facing docs had fallen behind `main` or contradicted each
other and the code. This PR brings them in line with what has shipped.
It changes documentation only.


**Corrected claims**
- README listed the Messages API as "🚧 Planned" while another README
section documents `/v1/messages`. It is now listed as shipped; only
stateful Messages stays planned.
- README and `docs/index.md` advertised "Background execution" and
gateway-executed file search. Neither exists yet: background mode is
#357, and `file_search` declarations parse but are dropped before
inference (`tool/normalize.rs`). Both claims are removed.
- `docs/api/index.md` quoted fixed WebSocket and executor limits (256
KiB SSE lines, 1 MiB events and response budget). These now come from
the configurable `[responses]` settings, which default to 16 MiB and 8
MiB.
- `docs/api/index.md` listed only some of the conditions that route a
Responses request through the executor. The list now also includes
non-function tools, `multi_agent.enabled`, and tool-search state,
matching `handler/http/responses.rs`.
- CHANGELOG listed Tavily under 0.8.0, but it merged on Sep 28, after
the Sep 19 release. The two Tavily entries move to `[Unreleased]`.

**Newly documented features**
- README: a multi-agent Responses section with an example and the
gateway's limits (`store: true`, HTTP/SSE only, default of 3 concurrent
subagents, no `max_tool_calls` or reasoning summaries). Also new rows in
the API table for `/v1/responses/compact`, the full Conversations
routes, `/v1/messages` with `/v1/messages/count_tokens`, and
Swagger/OpenAPI (`ENABLE_OPENAPI_DOCS`). The features list, diagram, and
tool ownership table now include MCP, the code interpreter, Claude Code,
compaction, and OpenTelemetry.
- `docs/api/index.md`: new sections for `GET
/v1/responses/{response_id}`, multi-agent, Conversations, and Messages.
- CHANGELOG `[Unreleased]` was empty. It now has entries for #345, #347,
#349, #351/#370, #354, #368, #369, #372/#373, #380, and #387.

**Roadmap**
- ROADMAP.md marks multi-agent HTTP execution as shipped, with WebSocket
injection (#300) and stateless requests (#393) still open. It adds a
status note for Messages, a code interpreter entry, and a file search
item linking #34 and #356.
- README "Roadmap at a Glance" checks off Messages and Conversations and
adds unchecked items for multi-agent, file search, and stateful
Messages.

**Smaller fixes**
- The repository layout in README and AGENTS.md now lists
`agentic-llm-d`, `agentic-cli-docs`, and `python/agentic_api/`.
- ARCHITECTURE.md's list of multi-agent rejections now includes
`max_tool_calls`, matching `executor/rehydrate.rs`.
- `mkdocs.yaml` adds the existing but unlinked `design/shell-tool.md` to
the nav.

**Not changed:** the README's "Rust 1.85+" badge is wrong (1.85 cannot
build the lockfile, see #377), but #379 already updates it to 1.88 along
with `rust-version` and a CI check, so this PR leaves it alone to avoid
a conflict.

Signed-off-by: haoshan98 <[email protected]>
@Zheng-Lu
Zheng-Lu deleted the feat/339-execution-traces branch October 9, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: request and execution traces across HTTP, WebSocket, and executor stages (#279 phase 2)

2 participants