Skip to content

fix(tracing): replace span.enter() across .await with .instrument()#4788

Merged
bug-ops merged 1 commit into
mainfrom
4777-span-instrumentation
Jun 5, 2026
Merged

fix(tracing): replace span.enter() across .await with .instrument()#4788
bug-ops merged 1 commit into
mainfrom
4777-span-instrumentation

Conversation

@bug-ops

@bug-ops bug-ops commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix 6 locations where a synchronous span.enter() guard was held across an .await boundary (!Send, causes incorrect trace parent-child relationships under tokio multi-thread) — replaced with .instrument(span).await or async move { ... }.instrument(span) for spawn() blocks.
  • Normalize 8 span name strings in zeph-tools from the inconsistent tool.* / scrape.* prefixes to the canonical tools.<subsystem>.<operation> convention from CLAUDE.md.

Files changed

File Change
zeph-core/src/agent/agent_access_impl.rs .instrument(span).await on semantic scan future
zeph-core/src/agent/mod.rs .instrument(span) on supervisor async move spawn block
zeph-context/src/fidelity.rs .instrument(span).await on timeout(p.chat(...))
zeph-skills/src/evaluator.rs .instrument(span) inside timeout async block
zeph-tools/src/shadow_probe.rs (×2) .instrument(span).await on both probe calls
zeph-tools/src/{scrape,shell/mod,diagnostics,file,search_code}.rs Span name renames

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools -- -D warnings — clean
  • cargo nextest run -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools — 3579/3579 passed
  • RUSTFLAGS="-D warnings" cargo check -p zeph-core -p zeph-context -p zeph-skills -p zeph-tools — clean

Notes

  • The mod.rs supervisor span becomes a sibling of bg_task instead of its child (span was moved from inside the async move block to the call site). Cosmetic trace-tree change only, no behavioral impact.
  • 4 additional 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:158 has extra record() fragility; P3: 3 locations in zeph-plugins).

Closes #4777, #4714

@bug-ops bug-ops added bug Something isn't working P3 Research — medium-high complexity labels Jun 5, 2026
@github-actions github-actions Bot added size/M Medium PR (51-200 lines) documentation Improvements or additions to documentation skills zeph-skills crate rust Rust code changes core zeph-core crate labels Jun 5, 2026
@bug-ops bug-ops force-pushed the 4777-span-instrumentation branch from 91e74d2 to 866c501 Compare June 5, 2026 11:16
@bug-ops bug-ops enabled auto-merge (squash) June 5, 2026 11:16
@bug-ops bug-ops force-pushed the 4777-span-instrumentation branch from 866c501 to f7598fd Compare June 5, 2026 11:22
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
@bug-ops bug-ops force-pushed the 4777-span-instrumentation branch from f7598fd to b294a5a Compare June 5, 2026 11:30
@bug-ops bug-ops merged commit 8f42975 into main Jun 5, 2026
32 checks passed
@bug-ops bug-ops deleted the 4777-span-instrumentation branch June 5, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation P3 Research — medium-high complexity rust Rust code changes size/M Medium PR (51-200 lines) skills zeph-skills crate

Projects

None yet

1 participant