-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(tracing): Add missing attributes in vercel-ai spans #18333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(tracing): Add missing attributes in vercel-ai spans #18333
Conversation
e14c708 to
830aa2e
Compare
size-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
Also, sort the fields in the integration test, in order to more easily se which fields were missing/misnamed in the fixture objects. Fix JS-1216
830aa2e to
f5b9b31
Compare
RulaKhaled
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic lgtm, I left some quick comments. We also need to a. update tests for Vercel v5 (it's a nested folder within vercel node integration tests) and b. run yarn fix in the root folder to fix lint issues
Also, sort the fields in the integration test, in order to more easily se which fields were missing/misnamed in the fixture objects. Fix JS-1216
f5b9b31 to
346d3b3
Compare
| } | ||
| const prompt = attributes[AI_PROMPT_ATTRIBUTE]; | ||
| if ( | ||
| typeof prompt === 'string' && | ||
| !attributes[GEN_AI_REQUEST_MESSAGES_ATTRIBUTE] && | ||
| !attributes[AI_PROMPT_MESSAGES_ATTRIBUTE] | ||
| ) { | ||
| const messages = convertPromptToMessages(prompt); | ||
| if (messages.length) span.setAttribute(GEN_AI_REQUEST_MESSAGES_ATTRIBUTE, getTruncatedJsonString(messages)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The createRunner() function call is missing an await keyword, causing runner to be a Promise.
Severity: HIGH | Confidence: High
🔍 Detailed Analysis
If createRunner() returns a Promise, then runner without await would be a Promise object, not the resolved value. Calling .expect() directly on a Promise object would result in a runtime error similar to 'TypeError: runner.expect is not a function' because Promises do not have an .expect() method. This causes the integration test to fail at runtime when executed, preventing verification of Vercel AI span attributes.
💡 Suggested Fix
Add the await keyword before the createRunner() call: const runner = await createRunner().
🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/core/src/tracing/vercel-ai/utils.ts#L93-L139
Potential issue: If `createRunner()` returns a Promise, then `runner` without `await`
would be a Promise object, not the resolved value. Calling `.expect()` directly on a
Promise object would result in a runtime error similar to 'TypeError: runner.expect is
not a function' because Promises do not have an `.expect()` method. This causes the
integration test to fail at runtime when executed, preventing verification of Vercel AI
span attributes.
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 4693704
Fix JS-1216
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).