Skip to content

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

Merged
bug-ops merged 1 commit into
mainfrom
4787-span-enter-await
Jun 5, 2026
Merged

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

Conversation

@bug-ops

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

Copy link
Copy Markdown
Owner

Summary

Changes

File Change
crates/zeph-core/src/agent/memcot/accumulator.rs Move span creation outside async move, apply .instrument(span) before Box::pin; fix Span::current().record() attribution
crates/zeph-plugins/src/manager.rs Convert add_remote, add_remote_ephemeral, download_and_extract to #[tracing::instrument]
crates/zeph-context/src/assembler.rs Add #[tracing::instrument(name = "context.assembler.gather", skip_all)]
CHANGELOG.md Update [Unreleased] Fixed section

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy -p zeph-core -p zeph-plugins -p zeph-context -- -D warnings — 0 warnings
  • cargo nextest run --workspace --lib --bins — 10454 passed, 0 failed
  • Impl-critic verified all 11 assembler.rs functions are instrumented
  • Tester confirmed 2 remaining span.enter() in manager.rs are in sync functions (safe)

Follow-up

Impl-critic found 6 additional span.enter() across .await instances outside this PR's scope: fidelity.rs:712, agent/mod.rs:3722, agent_access_impl.rs:67, evaluator.rs:206, shadow_probe.rs:145, shadow_probe.rs:180. A follow-up P3 issue will be filed after merge.

Closes #4787
Closes #4783

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Jun 5, 2026
Under tokio's multi-thread scheduler, holding an EnterGuard (_guard from
span.enter()) across an .await boundary causes spans to propagate to the
wrong task. Replace all four remaining instances with the correct idiom.

- accumulator.rs: move span creation outside async move block, apply
  .instrument(span) before Box::pin; eliminates erroneous
  Span::current().record() attribution after awaits
- manager.rs: convert add_remote, add_remote_ephemeral,
  download_and_extract to #[tracing::instrument], removing manual
  span.enter() guards entirely

Also add #[tracing::instrument] to ContextAssembler::gather (the only
uninstrumented function in the context assembly hot path) so every
per-turn assembler call appears in Perfetto/Jaeger traces.

Closes #4787
Closes #4783
@bug-ops bug-ops force-pushed the 4787-span-enter-await branch from 9328364 to d7e4373 Compare June 5, 2026 11:48
@bug-ops bug-ops merged commit f5a2e71 into main Jun 5, 2026
32 checks passed
@bug-ops bug-ops deleted the 4787-span-enter-await branch June 5, 2026 11:59
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 rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant