fix: preserve request correlation with root workflow and agent spans#1060
Conversation
🦋 Changeset detectedLatest commit: c5c448c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment has been minimized.
This comment has been minimized.
📝 WalkthroughWalkthroughThis PR introduces OpenTelemetry ambient span linking to preserve request correlation across root workflow and agent spans. It ensures root spans remain true roots when no explicit parent exists while maintaining request-level tracing through span links and combines ambient links with existing resume links in workflow scenarios. Changes
Sequence DiagramsequenceDiagram
participant Client as Client/Request
participant Workflow as Workflow<br/>TraceContext
participant Agent as Agent<br/>TraceContext
participant OTel as OpenTelemetry<br/>Context
participant Storage as Observability<br/>Storage
Client->>+Workflow: Initialize WorkflowTraceContext
Workflow->>OTel: Check for active span (ambient context)
OTel-->>Workflow: Return active request span
Workflow->>Workflow: Create root span (no explicit parent)
Workflow->>Workflow: Add ambient-parent link to request span
Workflow->>Workflow: Add resume link (if resumedFrom exists)
Workflow->>Storage: Store root span with links
Workflow-->>-Client: Trace initialized
Client->>+Agent: Initialize AgentTraceContext
Agent->>OTel: Resolve linked ambient span
OTel-->>Agent: Return active workflow span
Agent->>Agent: Create root span (no explicit parent)
Agent->>Agent: Add ambient-parent link to active span
Agent->>Storage: Store root span with link
Agent-->>-Client: Trace initialized
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying voltagent with
|
| Latest commit: |
c5c448c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://664a2660.voltagent.pages.dev |
| Branch Preview URL: | https://fix-observability-trace-root.voltagent.pages.dev |
PR Checklist
Please check if your PR fulfills the following requirements:
Bugs / Features
What is the current behavior?
What is the new behavior?
fixes (issue)
Notes for reviewers
Summary by cubic
Preserves request-level correlation while keeping workflow and agent root spans as true roots. Root spans now link to the active request span instead of being parented.
Written for commit c5c448c. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes