Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions js/.changeset/ai-sdk-v6-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
"@arizeai/openinference-vercel": minor
---

feat(openinference-vercel): add AI SDK v6 telemetry support

This release improves compatibility with AI SDK v6 telemetry while keeping best-effort compatibility with older AI SDK versions.

Key behavior:

- Prefer standard `gen_ai.*` attributes (OTel GenAI semantic conventions) when present
- Fall back to Vercel-specific `ai.*` attributes for data not available in `gen_ai.*` and for older SDK versions

Vercel-specific `ai.*` processing includes:

- Span kind determination from `operation.name`
- Embeddings (`ai.value`, `ai.embedding`, etc.)
- Tool calls (`ai.toolCall.*`)
- Metadata (`ai.telemetry.metadata.*`)
- Streaming metrics (`ai.response.msToFirstChunk`, etc.)
- Input/output messages from `ai.prompt.messages` and `ai.response.toolCalls`

Additional improvements:

- Root AI SDK spans now have a status set (`OK`/`ERROR`) based on the overall invocation result.

Notes:

- AI SDK telemetry is experimental; older versions are supported on a best-effort basis.

**Migration Guide:**

- If you are on AI SDK v6: no code changes required.
- If you are on older AI SDK versions: no code changes required; compatibility is best-effort.
2 changes: 1 addition & 1 deletion js/packages/openinference-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json; rimraf dist/test",
"type:check": "tsc --noEmit",
"test": "vitest --typecheck"
"test": "vitest run --typecheck"
},
"exports": {
".": {
Expand Down
6 changes: 3 additions & 3 deletions js/packages/openinference-genai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"name": "@arizeai/openinference-genai",
"version": "0.1.6",
"private": false,
"main": "dist/src/index.js",
"main": "dist/commonjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/src/index.d.ts",
"types": "dist/commonjs/index.d.ts",
"description": "OpenInference utilities for converting OpenTelemetry GenAI span attributes to OpenInference span attributes",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --build tsconfig.commonjs.json tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test dist/examples",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest --typecheck",
"test": "vitest run --typecheck",
"validate:invoke-agent": "tsx --env-file examples/.env examples/run-invoke-agent.ts",
"validate:invoke-rag": "tsx --env-file examples/.env examples/run-rag.ts"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest --typecheck",
"test": "vitest run --typecheck",
"validate:invoke-model": "tsx scripts/validate-invoke-model.ts",
"validate:converse-comprehensive": "tsx scripts/validate-converse-comprehensive.ts",
"validate:converse-stream": "tsx scripts/validate-converse-stream.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"type:check": "tsc --noEmit",
"test": "vitest --typecheck"
"test": "vitest run --typecheck"
},
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion js/packages/openinference-instrumentation-mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest --typecheck"
"test": "vitest run --typecheck"
},
"exports": {
".": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down
8 changes: 4 additions & 4 deletions js/packages/openinference-mastra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "tsc --build tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"type:check": "tsc --noEmit",
"test": "vitest"
"test": "vitest run"
},
"exports": {
".": {
Expand Down Expand Up @@ -43,9 +43,9 @@
"url": "https://github.com/Arize-ai/openinference/issues"
},
"dependencies": {
"@arizeai/openinference-core": "workspace:*",
"@arizeai/openinference-semantic-conventions": "workspace:*",
"@arizeai/openinference-vercel": "workspace:*"
"@arizeai/openinference-core": "2.0.5",
"@arizeai/openinference-semantic-conventions": "2.1.7",
"@arizeai/openinference-vercel": "2.5.5"
},
"devDependencies": {
"vitest": "^4.0.3"
Expand Down
18 changes: 11 additions & 7 deletions js/packages/openinference-mastra/src/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ import {
OpenInferenceSpanKind,
SemanticConventions,
} from "@arizeai/openinference-semantic-conventions";
import { addOpenInferenceAttributesToSpan } from "@arizeai/openinference-vercel/utils";
import { addOpenInferenceAttributesToSpan as addOpenInferenceAttributesToSpanVercel } from "@arizeai/openinference-vercel/utils";

import { diag } from "@opentelemetry/api";
import type { ReadableSpan } from "@opentelemetry/sdk-trace-base";

// openinference-vercel is typed against OTel v1 ReadableSpan, while Mastra uses OTel v2.
// At runtime we only need span.attributes, so keep the call but erase the type.
const addOpenInferenceAttributesToSpan =
addOpenInferenceAttributesToSpanVercel as unknown as (span: {
attributes: Record<string, unknown>;
}) => void;

import {
MASTRA_AGENT_SPAN_NAME_PREFIXES,
MASTRA_INTERNAL_SPAN_NAME_PREFIX,
Expand Down Expand Up @@ -134,12 +141,9 @@ export const addOpenInferenceAttributesToMastraSpan = (span: ReadableSpan) => {
*/
export const processMastraSpanAttributes = (span: ReadableSpan): void => {
addOpenInferenceProjectResourceAttributeSpan(span);
addOpenInferenceAttributesToSpan({
...span,
instrumentationLibrary: {
name: "@arizeai/openinference-mastra",
},
});
addOpenInferenceAttributesToSpan(
span as unknown as { attributes: Record<string, unknown> },
);
addOpenInferenceAttributesToMastraSpan(span);
};

Expand Down
Loading
Loading