Repository navigation
fix: activate activity trace context - #381
Merged
wangbill (YunchuWang) merged 1 commit intoOct 7, 2026
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e0af01a5-0dfa-4e71-a660-c4186e65d7e0
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation correctly preserves activity trace context and is covered across key execution paths.
Review effort: Balanced
Findings: None
What changed in this PR
Activates the OpenTelemetry activity execution span while registered activity code runs.
Changes:
- Scopes activity execution under its server span.
- Adds async, concurrency, failure, restoration, and tracing-unavailable tests.
- Documents the fix in the changelog.
| File | Description |
|---|---|
task-hub-grpc-worker.ts |
Activates the activity span around user code. |
worker-tracing.spec.ts |
Adds worker-level tracing coverage. |
CHANGELOG.md |
Records the activity tracing fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kaibocai (kaibocai)
approved these changes
Oct 7, 2026
wangbill (YunchuWang)
deleted the
yunchuwang-activate-activity-trace-context
branch
October 7, 2026 16:41
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
What changed?
Why is this change needed?
startSpanForTaskExecution()created the server span but did not make it active, so spans created by user activity code could become roots or inherit an unrelated ambient span.Before: the Durable Task server span was emitted but not active during
ActivityExecutor.execute().After: only the awaited activity execution is scoped under that span. Existing parent extraction, span status/error handling, version-mismatch behavior, response delivery, tracing-unavailable behavior, and the single
finallyspan end remain unchanged. There are no public API, protocol, backend, dependency, or orchestration execution changes.Before / after trace
Both captures use the same activity workload and fixed synthetic IDs.
startSpan()alone does not activate context; this PR scopes onlyActivityExecutor.execute()under the Durable Task activity server span.Before (PR base)
The user spans created before and after the async boundary are separate roots (
parentSpanId: null) instead of children of the Durable Task activity server span2222222222222222.After (PR head)
The same user spans both inherit
parentSpanId: 2222222222222222and remain on the Durable Task trace across the async boundary.Issues / work items
Project checklist
CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
AI verification (required if AI was used):
Testing
Automated tests
npm test -w @microsoft/durabletask-js -- --runTestsByPath test/tracing.spec.ts test/worker-tracing.spec.ts test/activity_executor.spec.ts test/worker-activity-response.spec.ts test/versioned-dispatch-grpc.spec.ts— 5 suites, 137 tests passed.npm run build:core— passed.npx eslint packages\durabletask-js\src\worker\task-hub-grpc-worker.ts packages\durabletask-js\test\worker-tracing.spec.ts— passed.npx prettier --check CHANGELOG.md— passed.npx prettier --check packages\durabletask-js\src\worker\task-hub-grpc-worker.ts --range-start 51884 --range-end 52371— passed.npx prettier --check packages\durabletask-js\test\worker-tracing.spec.ts --range-start 2027 --range-end 4207— passed.npx prettier --check packages\durabletask-js\test\worker-tracing.spec.ts --range-start 18630 --range-end 25026— passed.git diff --check— passed.Manual validation (only if runtime/behavior changed)
Notes for reviewers