Skip to content

feat(ai): wrap the model call in telemetry context#15479

Merged
aayush-kapoor merged 3 commits into
mainfrom
aayush/context-wrapping
May 27, 2026
Merged

feat(ai): wrap the model call in telemetry context#15479
aayush-kapoor merged 3 commits into
mainfrom
aayush/context-wrapping

Conversation

@aayush-kapoor
Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor commented May 20, 2026

Background

continuing from #14732

There seems to be a regression with telemetry spans from v6 -> v7 where the AI Gateway stream fetch request spans seem to be disconnected from the AI SDK traces.

For v6, those requests were visibly child spans. In v7, the AI Gateway requests are not child spans.

The reason seems to be that in v6, we used to wrap the entire doStream model call with OpenTelemetry context and so all subsequent calls/requests were nested properly

Summary

introduce another helper execute composite (similar to what we do for tool execution executeTools) that will help wrap the language model calls for generate text and stream text

Manual Verification

na

Checklist

  • All commits are signed (PRs with unsigned commits cannot be merged)
  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

monitor issues for any regressions

@aayush-kapoor aayush-kapoor merged commit 594029e into main May 27, 2026
48 checks passed
@aayush-kapoor aayush-kapoor deleted the aayush/context-wrapping branch May 27, 2026 00:43
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.154 github npm
@ai-sdk/angular 3.0.0-canary.154 github npm
@ai-sdk/langchain 3.0.0-canary.154 github npm
@ai-sdk/llamaindex 3.0.0-canary.154 github npm
@ai-sdk/mcp 2.0.0-canary.55 github npm
@ai-sdk/otel 1.0.0-canary.100 github npm
@ai-sdk/react 4.0.0-canary.156 github npm
@ai-sdk/rsc 3.0.0-canary.155 github npm
@ai-sdk/svelte 5.0.0-canary.154 github npm
@ai-sdk/vue 4.0.0-canary.154 github npm
@ai-sdk/workflow 1.0.0-canary.71 github npm

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.

2 participants