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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
GEN_AI_USAGE_OUTPUT_TOKENS,
GEN_AI_USAGE_TOTAL_TOKENS,
} from '@sentry/conventions/attributes';
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../../../../../packages/core/src/tracing/ai/gen-ai-attributes';
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../../../../../packages/server-utils/src/ai/core/gen-ai-attributes';
import { getStringAttributeValue, isOrchestrionEnabled } from '../../../utils';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';

Expand Down
3 changes: 1 addition & 2 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export {
// eslint-disable-next-line typescript/no-deprecated
inboundFiltersIntegration,
instrumentGoogleGenAIClient,
instrumentAnthropicAiClient,
eventFiltersIntegration,
linkedErrorsIntegration,
requestDataIntegration,
Expand Down Expand Up @@ -127,7 +126,7 @@ export { httpServerIntegration } from './integrations/httpServer';
export { fetchIntegration } from './integrations/fetch';
export { spotlightIntegration } from './integrations/spotlight';
export { vercelAIIntegration } from './integrations/tracing/vercelai';
export { prismaIntegration, instrumentOpenAiClient } from '@sentry/server-utils';
export { prismaIntegration, instrumentOpenAiClient, instrumentAnthropicAiClient } from '@sentry/server-utils';

// eslint-disable-next-line typescript/no-deprecated
export { instrumentD1WithSentry } from './instrumentations/worker/instrumentD1';
Expand Down
15 changes: 0 additions & 15 deletions packages/core/src/server-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ export { addVercelAiProcessors, getProviderMetadataAttributes } from './tracing/
export { getTruncatedJsonString, shouldEnableTruncation, resolveAIRecordingOptions } from './tracing/ai/utils';
export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils';
export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants';
export {
instrumentAnthropicAiClient,
extractRequestAttributes as extractAnthropicRequestAttributes,
addPrivateRequestAttributes as addAnthropicRequestAttributes,
addResponseAttributes as addAnthropicResponseAttributes,
} from './tracing/anthropic-ai';
export { instrumentAsyncIterableStream, instrumentMessageStream } from './tracing/anthropic-ai/streaming';
export { ANTHROPIC_AI_INTEGRATION_NAME } from './tracing/anthropic-ai/constants';
export {
instrumentGoogleGenAIClient,
extractRequestAttributes as extractGoogleGenAIRequestAttributes,
Expand All @@ -93,13 +85,6 @@ export { LANGGRAPH_INTEGRATION_NAME } from './tracing/langgraph/constants';
export type { LangGraphOptions, LangGraphIntegration, CompiledGraph } from './tracing/langgraph/types';
export { instrumentWorkersAiClient } from './tracing/workers-ai';
export type { WorkersAiClient, WorkersAiOptions } from './tracing/workers-ai/types';
export type {
AnthropicAiClient,
AnthropicAiOptions,
// eslint-disable-next-line typescript/no-deprecated
AnthropicAiInstrumentedMethod,
AnthropicAiResponse,
} from './tracing/anthropic-ai/types';
Comment on lines -96 to -102

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

h: Same as in the other pr. Maybe I'm misreading somthing but looks like these are just dropped?

@nicohrubec nicohrubec Aug 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

correct, don't think we need to publicly expose these. I'll add a migration entry

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll put it on top of the stack so we don't have to rerun CI for everything

export type {
GoogleGenAIClient,
GoogleGenAIChat,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export type {
SerializedStreamedSpanContainer,
StreamedSpanJSON,
} from './types/span';
export type { SpanStatus } from './types/spanStatus';
export type { SpanStatus, SpanStatusType } from './types/spanStatus';
export type { Log, LogSeverityLevel } from './types/log';
export type { SpanLink } from './types/link';
export type {
Expand Down
7 changes: 4 additions & 3 deletions packages/core/test/lib/utils/ai/providerSkip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import {
_INTERNAL_clearAiProviderSkips,
_INTERNAL_shouldSkipAiProviderWrapping,
_INTERNAL_skipAiProviderWrapping,
ANTHROPIC_AI_INTEGRATION_NAME,
GOOGLE_GENAI_INTEGRATION_NAME,
OPENAI_INTEGRATION_NAME,
} from '../../../../src/index';

const OPENAI_INTEGRATION_NAME = 'OpenAI';
const ANTHROPIC_AI_INTEGRATION_NAME = 'Anthropic_AI';
const GOOGLE_GENAI_INTEGRATION_NAME = 'Google_GenAI';

describe('AI Provider Skip', () => {
beforeEach(() => {
_INTERNAL_clearAiProviderSkips();
Expand Down
3 changes: 1 addition & 2 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export {
vercelAiIntegration as vercelAIIntegration,
} from '@sentry/server-utils/orchestrion';
export { redisIntegration } from './integrations/tracing/redis';
export { prismaIntegration, instrumentOpenAiClient } from '@sentry/server-utils';
export { prismaIntegration, instrumentOpenAiClient, instrumentAnthropicAiClient } from '@sentry/server-utils';
export { setupHapiErrorHandler } from './integrations/tracing/hapi';
export { setupKoaErrorHandler } from './integrations/tracing/koa';
export {
Expand Down Expand Up @@ -133,7 +133,6 @@ export {
updateSpanName,
supabaseIntegration,
instrumentSupabaseClient,
instrumentAnthropicAiClient,
instrumentGoogleGenAIClient,
zodErrorsIntegration,
profiler,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InstrumentedMethodRegistry } from '../ai/utils';
import type { InstrumentedMethodRegistry } from '../core/utils';

export const ANTHROPIC_AI_INTEGRATION_NAME = 'Anthropic_AI' as const;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable typescript-eslint/no-deprecated */
import { captureException } from '../../exports';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes';
import { SPAN_STATUS_ERROR } from '../../tracing';
import { startSpan, startSpanManual } from '../../tracing/trace';
import type { Span, SpanAttributeValue } from '../../types/span';
import {
captureException,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SPAN_STATUS_ERROR,
startSpan,
startSpanManual,
} from '@sentry/core';
import type { Span, SpanAttributeValue } from '@sentry/core';
import {
GEN_AI_OPERATION_NAME,
GEN_AI_PROMPT,
Expand All @@ -20,14 +23,14 @@ import {
GEN_AI_RESPONSE_TOOL_CALLS,
GEN_AI_SYSTEM,
} from '@sentry/conventions/attributes';
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../ai/gen-ai-attributes';
import type { InstrumentedMethodEntry } from '../ai/utils';
import { GEN_AI_REQUEST_STREAM_ATTRIBUTE } from '../core/gen-ai-attributes';
import type { InstrumentedMethodEntry } from '../core/utils';
import {
resolveAIRecordingOptions,
setTokenUsageAttributes,
shouldEnableTruncation,
wrapPromiseWithMethods,
} from '../ai/utils';
} from '../core/utils';
import { ANTHROPIC_METHOD_REGISTRY } from './constants';
import { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';
import type { AnthropicAiOptions, AnthropicAiResponse, AnthropicAiStreamingEvent, ContentBlock } from './types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { captureException } from '../../exports';
import { SPAN_STATUS_ERROR } from '../../tracing';
import type { Span } from '../../types/span';
import { endStreamSpan } from '../ai/utils';
import { captureException, SPAN_STATUS_ERROR } from '@sentry/core';
import type { Span } from '@sentry/core';
import { endStreamSpan } from '../core/utils';
import type { AnthropicAiStreamingEvent } from './types';
import { mapAnthropicErrorToStatusMessage } from './utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { captureException } from '../../exports';
import { SPAN_STATUS_ERROR } from '../../tracing';
import type { Span } from '../../types/span';
import type { SpanStatusType } from '../../types/spanStatus';
import { captureException, SPAN_STATUS_ERROR, stringify } from '@sentry/core';
import type { Span, SpanStatusType } from '@sentry/core';
import { GEN_AI_INPUT_MESSAGES, GEN_AI_SYSTEM_INSTRUCTIONS } from '@sentry/conventions/attributes';
import { extractSystemInstructions, getTruncatedJsonString } from '../ai/utils';
import { stringify } from '../../utils/string';
import { extractSystemInstructions, getTruncatedJsonString } from '../core/utils';
import type { AnthropicAiResponse } from './types';

/**
Expand Down
1 change: 1 addition & 0 deletions packages/server-utils/src/ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*/

export { instrumentOpenAiClient } from './openai';
export { instrumentAnthropicAiClient } from './anthropic-ai';
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { GEN_AI_REQUEST_MODEL } from '@sentry/conventions/attributes';
import * as diagnosticsChannel from 'node:diagnostics_channel';
import type { AnthropicAiOptions, AnthropicAiResponse, IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';
import type { IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';
import {
_INTERNAL_shouldSkipAiProviderWrapping,
addAnthropicRequestAttributes,
addAnthropicResponseAttributes,
defineIntegration,
extractAnthropicRequestAttributes,
instrumentAsyncIterableStream,
instrumentMessageStream,
resolveAIRecordingOptions,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
shouldEnableTruncation,
startInactiveSpan,
} from '@sentry/core';
import { resolveAIRecordingOptions, shouldEnableTruncation } from '../../ai/core/utils';
import { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes } from '../../ai/anthropic-ai';
import { instrumentAsyncIterableStream, instrumentMessageStream } from '../../ai/anthropic-ai/streaming';
import type { AnthropicAiOptions, AnthropicAiResponse } from '../../ai/anthropic-ai/types';
import { CHANNELS } from '../../orchestrion/channels';
import { bindTracingChannelToSpan } from '../../tracing-channel';
import { anthropicAiModuleNames } from '../../orchestrion/config/anthropic-ai';
Expand Down Expand Up @@ -60,7 +57,7 @@ function instrumentAnthropic(options: AnthropicAiOptions): void {
data => createGenAiSpan(data, operation, methodPath, options),
{
beforeSpanEnd: (span, data) => {
addAnthropicResponseAttributes(
addResponseAttributes(
span,
data.result as AnthropicAiResponse,
resolveAIRecordingOptions(options).recordOutputs,
Expand Down Expand Up @@ -103,7 +100,7 @@ function createGenAiSpan(
const { recordInputs } = resolveAIRecordingOptions(options);
const enableTruncation = shouldEnableTruncation(options.enableTruncation);

const attributes = extractAnthropicRequestAttributes(args, methodPath, operation);
const attributes = extractRequestAttributes(args, methodPath, operation);
const model = (attributes[GEN_AI_REQUEST_MODEL] as string) || 'unknown';
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = ORIGIN;

Expand All @@ -114,7 +111,7 @@ function createGenAiSpan(
});

if (recordInputs && params) {
addAnthropicRequestAttributes(span, params, enableTruncation);
addPrivateRequestAttributes(span, params, enableTruncation);
}

return span;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
_INTERNAL_getLangChainEmbeddingsSpanOptions,
_INTERNAL_mergeLangChainCallbackHandler,
_INTERNAL_skipAiProviderWrapping,
ANTHROPIC_AI_INTEGRATION_NAME,
createLangChainCallbackHandler,
defineIntegration,
GOOGLE_GENAI_INTEGRATION_NAME,
LANGCHAIN_INTEGRATION_NAME,
startInactiveSpan,
} from '@sentry/core';
import { ANTHROPIC_AI_INTEGRATION_NAME } from '../../ai/anthropic-ai/constants';
import { OPENAI_INTEGRATION_NAME } from '../../ai/openai/constants';
import { CHANNELS } from '../../orchestrion/channels';
import { langchainEmbeddingsChannels } from '../../orchestrion/config/langchain';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
mapAnthropicErrorToStatusMessage,
messagesFromParams,
setMessagesAttribute,
} from '../../../src/tracing/anthropic-ai/utils';
import type { Span } from '../../../src/types/span';
} from '../../../../src/ai/anthropic-ai/utils';
import type { Span } from '@sentry/core';

describe('anthropic-ai-utils', () => {
describe('mapAnthropicErrorToStatusMessage', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/vercel-edge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export {
inboundFiltersIntegration,
instrumentStateGraph,
instrumentGoogleGenAIClient,
instrumentAnthropicAiClient,
eventFiltersIntegration,
linkedErrorsIntegration,
requestDataIntegration,
Expand Down Expand Up @@ -107,7 +106,7 @@ export {
withStreamedSpan,
spanStreamingIntegration,
} from '@sentry/core';
export { instrumentOpenAiClient } from '@sentry/server-utils/no-diagnostic-channels';
export { instrumentOpenAiClient, instrumentAnthropicAiClient } from '@sentry/server-utils/no-diagnostic-channels';

export { VercelEdgeClient } from './client';
export { getDefaultIntegrations, init } from './sdk';
Expand Down
Loading