perf(context),refactor(llm): add fidelity tracing spans and extract response body helper#4891
Merged
Conversation
bug-ops
force-pushed
the
4872-fidelity-tracing
branch
from
June 5, 2026 23:25
e0907b5 to
5c26e92
Compare
bug-ops
enabled auto-merge (squash)
June 5, 2026 23:25
…esponse body helper Add `#[tracing::instrument]` to `embed_prepass_dyn` and `render_compressed` in `zeph-context/fidelity.rs`; both were invisible to local Chrome JSON traces. All five async hot-path functions in fidelity.rs now emit `context.fidelity.*` spans. Closes #4872. Add `check_response` and `read_response_body` helpers to `zeph-llm/src/http.rs`. Replace the duplicated three-line `status + text().await + map_error_response` pattern at eight call sites across `openai/mod.rs` and `claude/mod.rs`. Streaming call sites and those with custom retry or error-variant logic are left unchanged. Closes #4877.
bug-ops
force-pushed
the
4872-fidelity-tracing
branch
from
June 5, 2026 23:34
5c26e92 to
6e6bfc3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#[tracing::instrument]toembed_prepass_dynandrender_compressedinzeph-context/fidelity.rs. Both async hot-path functions were invisible to local Chrome JSON traces and Jaeger — they absorbed all their latency into the parentAgentContextServicespan. All five production async fns infidelity.rsnow emitcontext.fidelity.*spans.check_responseandread_response_bodyhelpers tozeph-llm/src/http.rs. Replace the duplicated three-linestatus + text().await + map_error_responsepattern at eight call sites acrossopenai/mod.rs(5 sites) andclaude/mod.rs(3 sites). Streaming call sites and those with custom retry/error-variant logic are left unchanged.Changed files
crates/zeph-context/src/fidelity.rs— 2 new#[tracing::instrument]attributescrates/zeph-llm/src/http.rs— 2 new pub(crate) async helperscrates/zeph-llm/src/openai/mod.rs— 5 call sites simplifiedcrates/zeph-llm/src/claude/mod.rs— 3 call sites simplifiedCHANGELOG.md— [Unreleased] section updatedTest plan
cargo nextest run --workspace --lib --bins→ 10510 passedcargo +nightly fmt --check→ cleanRUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler→ cleancontext.fidelity.embed_prepass_dynandcontext.fidelity.render_compressedspans appear in local Chrome JSON trace after a session withmemory.n.enabled = trueCloses #4872
Closes #4877