Skip to content
Open
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
8 changes: 6 additions & 2 deletions packages/cloudflare/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

import type { IntegrationFn } from '@sentry/core';
import { defineIntegration, extendIntegration } from '@sentry/core';
import { addVercelAiProcessors, vercelAiIntegration, type VercelAiOptions } from '@sentry/server-utils';
import {
addVercelAiProcessors,
vercelAIIntegration as channelVercelAIIntegration,
type VercelAiOptions,
} from '@sentry/server-utils';

const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
const inner = vercelAiIntegration(options);
const inner = channelVercelAIIntegration(options);

return extendIntegration(inner, {
options,
Expand Down
1 change: 0 additions & 1 deletion packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
vercelAiIntegration,
Comment thread
cursor[bot] marked this conversation as resolved.
} from '@sentry/server-utils/orchestrion';
export { otlpIntegration, getOtlpTracesEndpoint } from '@sentry/server-utils/no-diagnostic-channels';
// Deprecated aliases kept for back-compat. Each forwards to the shared
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { IntegrationFn } from '@sentry/core';
import { defineIntegration, extendIntegration } from '@sentry/core';
import {
addVercelAiProcessors,
vercelAiIntegration as serverUtilsVercelAiIntegration,
vercelAIIntegration as serverUtilsVercelAiIntegration,
type VercelAiOptions,
} from '@sentry/server-utils';

Expand Down
4 changes: 2 additions & 2 deletions packages/deno/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
vercelAiIntegration,
vercelAIIntegration,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The Deno SDK's getDefaultIntegrations uses the generic vercelAIIntegration, bypassing the Deno-specific wrapper and its necessary event processors.
Severity: MEDIUM

Suggested Fix

In packages/deno/src/sdk.ts, change the import for vercelAIIntegration to use the local, Deno-specific wrapper from ./integrations/tracing/vercelai instead of the one from @sentry/server-utils/orchestrion. This will ensure that addVercelAiProcessors is called.

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/deno/src/sdk.ts#L37

Potential issue: The Deno SDK's `getDefaultIntegrations` function incorrectly imports
`vercelAIIntegration` from `@sentry/server-utils/orchestrion` instead of using the
Deno-specific wrapper from `./integrations/tracing/vercelai`. The Deno wrapper is
responsible for calling `addVercelAiProcessors`, which adds platform-specific event
processors for Vercel AI tracing. By using the generic server-utils integration
directly, these Deno-specific processors are no longer added during default SDK
initialization, leading to a functional regression in Vercel AI tracing support for
Deno.

Also affects:

  • packages/deno/src/sdk.ts:69~69

Did we get this right? 👍 / 👎 to inform future reviews.

} from '@sentry/server-utils/orchestrion';
import { DenoClient } from './client';
import { breadcrumbsIntegration } from './integrations/breadcrumbs';
Expand Down Expand Up @@ -66,7 +66,7 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
denoHttpIntegration(),
denoRedisIntegration(),
graphqlDiagnosticsIntegration(),
vercelAiIntegration(),
vercelAIIntegration(),
// orchestrion-based instrumentations. We add a deliberate list here rather
// than every channel integration: each one needs a Deno test proving it
// records spans.
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
vercelAiIntegration as vercelAIIntegration,
vercelAIIntegration,
} from '@sentry/server-utils/orchestrion';
export { redisIntegration } from './integrations/tracing/redis';
export {
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/tracing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
vercelAiIntegration,
vercelAIIntegration,
} from '@sentry/server-utils/orchestrion';
import { fastifyIntegration } from './fastify';
import { redisIntegration } from './redis';
Expand Down Expand Up @@ -52,7 +52,7 @@ export function getAutoPerformanceIntegrations(): Integration[] {
// LangChain must come first to disable AI provider integrations before they instrument
langChainIntegration(),
langGraphIntegration(),
vercelAiIntegration(),
vercelAIIntegration(),
openAIIntegration(),
anthropicIntegration(),
googleGenAIIntegration(),
Expand Down
2 changes: 1 addition & 1 deletion packages/server-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type {
} from './tracing-channel';
export type { InstrumentationConfig } from './orchestrion';
export type { GenAiOptions } from './ai/core/utils';
export { vercelAiIntegration, type VercelAiOptions } from './vercel-ai';
export { vercelAIIntegration, type VercelAiOptions } from './vercel-ai';
export {
fastifyIntegration,
// oxlint-disable-next-line typescript/no-deprecated
Expand Down
10 changes: 5 additions & 5 deletions packages/server-utils/src/integrations/vercel-ai.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { Client, IntegrationFn } from '@sentry/core';
import { defineIntegration, extendIntegration } from '@sentry/core';
import { vercelAiIntegration as baseVercelAiIntegration } from '../vercel-ai';
import { vercelAIIntegration as baseVercelAIIntegration } from '../vercel-ai';
import * as dc from 'node:diagnostics_channel';
import { vercelAiModuleNames } from '../orchestrion/config/vercel-ai';
import { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';
import { subscribeVercelAiOrchestrionChannels } from '../vercel-ai/vercel-ai-orchestrion-subscriber';

type VercelAiOptions = Parameters<typeof baseVercelAiIntegration>[0];
type VercelAiOptions = Parameters<typeof baseVercelAIIntegration>[0];

// In channel-based (orchestrion) mode we emit our own `gen_ai.*` spans from the
// diagnostics channels. The `ai` SDK would otherwise emit its own native
Expand All @@ -16,8 +16,8 @@ type VercelAiOptions = Parameters<typeof baseVercelAiIntegration>[0];
// `experimental_telemetry.isEnabled` to `false`, so `ai` falls back to its
// internal no-op tracer and never creates the native spans in the first place.
// See `subscribeVercelAiOrchestrionChannels`.
const _vercelAiIntegration = ((options: VercelAiOptions = {}) => {
const parentIntegration = baseVercelAiIntegration(options);
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
const parentIntegration = baseVercelAIIntegration(options);

// The native `ai:telemetry` half is the base integration's own `setupOnce`; the
// orchestrion half registers lazily via `setup`, only once `ai` is injected.
Expand All @@ -38,4 +38,4 @@ function instrumentVercelAiOrchestrion(options: VercelAiOptions): void {
* - v7 via native `ai:telemetry` tracing channel
* - v4, v5 & v6 via orchestrion `orchestrion:ai:*` channels
*/
export const vercelAiIntegration = defineIntegration(_vercelAiIntegration);
export const vercelAIIntegration = defineIntegration(_vercelAIIntegration);
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const CHANNEL_INTEGRATION_DEFINITIONS = [
{ exportName: 'openAIIntegration', modules: ['openai'] },
{ exportName: 'anthropicIntegration', modules: ['@anthropic-ai/sdk'] },
{ exportName: 'googleGenAIIntegration', modules: ['@google/genai'] },
{ exportName: 'vercelAiIntegration', modules: ['ai'] },
{ exportName: 'vercelAIIntegration', modules: ['ai'] },
{ exportName: 'amqplibIntegration', modules: ['amqplib'] },
{ exportName: 'hapiIntegration', modules: ['@hapi/hapi'] },
{ exportName: 'expressIntegration', modules: ['express', 'router'] },
Expand Down
6 changes: 3 additions & 3 deletions packages/server-utils/src/orchestrion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { openAIIntegration } from '../integrations/openai';
import { postgresIntegration } from '../integrations/postgres';
import { postgresJsIntegration } from '../integrations/postgres-js';
import { tediousIntegration } from '../integrations/tedious';
import { vercelAiIntegration } from '../integrations/vercel-ai';
import { vercelAIIntegration } from '../integrations/vercel-ai';
import { expressIntegration } from '../integrations/express';
import { firebaseIntegration } from '../integrations/firebase';

Expand Down Expand Up @@ -61,7 +61,7 @@ export {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
vercelAiIntegration,
vercelAIIntegration,
expressIntegration,
firebaseIntegration,
};
Expand Down Expand Up @@ -110,7 +110,7 @@ export const channelIntegrations = {
googleGenAIIntegration,
langChainIntegration,
langGraphIntegration,
vercelAiIntegration,
vercelAIIntegration,
amqplibIntegration,
hapiIntegration,
koaIntegration,
Expand Down
4 changes: 2 additions & 2 deletions packages/server-utils/src/vercel-ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as dc from 'node:diagnostics_channel';
/** Options for the Vercel AI integration. */
export type VercelAiOptions = GenAiOptions;

const _vercelAiIntegration = ((options: VercelAiOptions = {}) => {
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
return {
name: 'VercelAI' as const,
setupOnce() {
Expand All @@ -27,4 +27,4 @@ const _vercelAiIntegration = ((options: VercelAiOptions = {}) => {
/**
* Auto-instrument the `ai` SDK's native telemetry tracing channel (ai >= 7).
*/
export const vercelAiIntegration = defineIntegration(_vercelAiIntegration);
export const vercelAIIntegration = defineIntegration(_vercelAIIntegration);