Skip to content

fix: include same-batch events in tracing processing#275

Open
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/fix-tracing-same-batch-events
Open

fix: include same-batch events in tracing processing#275
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/fix-tracing-same-batch-events

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #229

… same-batch events

processNewEventsForTracing() only indexed pastEvents when building its
scheduling-event lookup maps. When a task was scheduled and completed
within the same event batch (both in newEvents), the corresponding
tracing span was silently dropped because the scheduling event was
never indexed.

Fix: also index newEvents into the lookup maps so that same-batch
completions can find their scheduling counterparts.

Added 4 new test cases covering same-batch scenarios for:
- Activity scheduled + completed in same batch
- Activity scheduled + failed in same batch
- Sub-orchestration created + completed in same batch
- Timer created + fired in same batch

Fixes #229

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a tracing/observability gap in the Durable Task JS SDK where retroactive spans could be silently skipped when a scheduling event and its completion/failure arrive in the same newEvents batch (fast activities, sub-orchestrations, and timers). It aligns span emission with actual history availability by indexing scheduling events from both past and current event batches.

Changes:

  • Extend processNewEventsForTracing() to index scheduling events from newEvents in addition to pastEvents, enabling same-batch completion lookups.
  • Add unit tests covering same-batch activity completion/failure, sub-orchestration completion, and timer firing span emission.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/durabletask-js/src/tracing/trace-helper.ts Index scheduling events from both pastEvents and newEvents so same-batch completions can emit retroactive spans.
packages/durabletask-js/test/tracing.spec.ts Adds regression tests ensuring spans are emitted when scheduling + completion/failure occur within the same newEvents batch.

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.

[copilot-finds] Bug: processNewEventsForTracing only indexes pastEvents, silently dropping tracing spans for same-batch completions

3 participants