fix(tracing): replace span.enter() across .await with .instrument()#4788
Merged
Conversation
91e74d2 to
866c501
Compare
4 tasks
866c501 to
f7598fd
Compare
Six async functions held a synchronous span guard across an .await
boundary. The guard is !Send and causes incorrect parent-child span
relationships when tokio polls the future on a different thread.
Replace all six with .instrument(span).await or, for async move blocks
passed to spawn(), with async move { ... }.instrument(span).
Also normalize eight span name strings in zeph-tools (scrape.rs,
shell/mod.rs, diagnostics.rs, file.rs, search_code.rs) from the
inconsistent tool.*/scrape.* prefixes to the canonical
tools.<subsystem>.<operation> convention.
Closes #4777, #4714
f7598fd to
b294a5a
Compare
This was referenced Jun 5, 2026
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
span.enter()guard was held across an.awaitboundary (!Send, causes incorrect trace parent-child relationships under tokio multi-thread) — replaced with.instrument(span).awaitorasync move { ... }.instrument(span)forspawn()blocks.zeph-toolsfrom the inconsistenttool.*/scrape.*prefixes to the canonicaltools.<subsystem>.<operation>convention from CLAUDE.md.Files changed
zeph-core/src/agent/agent_access_impl.rs.instrument(span).awaiton semantic scan futurezeph-core/src/agent/mod.rs.instrument(span)on supervisorasync movespawn blockzeph-context/src/fidelity.rs.instrument(span).awaitontimeout(p.chat(...))zeph-skills/src/evaluator.rs.instrument(span)insidetimeoutasync blockzeph-tools/src/shadow_probe.rs(×2).instrument(span).awaiton both probe callszeph-tools/src/{scrape,shell/mod,diagnostics,file,search_code}.rsTest plan
cargo +nightly fmt --check— cleancargo clippy -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools -- -D warnings— cleancargo nextest run -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools— 3579/3579 passedRUSTFLAGS="-D warnings" cargo check -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools— cleanNotes
mod.rssupervisor span becomes a sibling ofbg_taskinstead of its child (span was moved from inside theasync moveblock to the call site). Cosmetic trace-tree change only, no behavioral impact.span.enter()anti-patterns were found outside this PR's scope during review: tracked in bug(core): span.enter() across .await anti-pattern in 4 remaining locations #4787 (P2:memcot/accumulator.rs:158has extrarecord()fragility; P3: 3 locations inzeph-plugins).Closes #4777, #4714