Skip to content

Commit 3ef0c4a

Browse files
committed
renames
1 parent 744d63d commit 3ef0c4a

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

packages/core/src/tracing/vercel-ai/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ import {
1919
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
2020
GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE,
2121
} from '../ai/gen-ai-attributes';
22-
import { EMBEDDINGS_OPS, GENERATE_CONTENT_OPS, INVOKE_AGENT_OPS, RERANK_OPS, toolCallSpanContextMap } from './constants';
22+
import {
23+
EMBEDDINGS_OPS,
24+
GENERATE_CONTENT_OPS,
25+
INVOKE_AGENT_OPS,
26+
RERANK_OPS,
27+
toolCallSpanContextMap,
28+
} from './constants';
2329
import type { TokenSummary } from './types';
2430
import {
2531
accumulateTokensForParent,

packages/node/src/integrations/tracing/vercelai/instrumentation.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
22
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
3-
import type { Span } from '@sentry/core';
43
import {
54
_INTERNAL_cleanupToolCallSpanContext,
65
_INTERNAL_getSpanContextForToolCallId,
@@ -83,7 +82,7 @@ function isToolResult(obj: unknown): obj is { type: 'tool-result'; toolCallId: s
8382
* Check for tool errors in the result and capture them
8483
* Tool errors are not rejected in Vercel V5, it is added as metadata to the result content
8584
*/
86-
export function _INTERNAL_checkResultForToolErrors(result: unknown): void {
85+
export function checkResultForToolErrors(result: unknown): void {
8786
if (typeof result !== 'object' || result === null || !('content' in result)) {
8887
return;
8988
}
@@ -265,7 +264,7 @@ export class SentryVercelAiInstrumentation extends InstrumentationBase {
265264
},
266265
() => {},
267266
result => {
268-
_INTERNAL_checkResultForToolErrors(result);
267+
checkResultForToolErrors(result);
269268
},
270269
);
271270
},

packages/node/test/integrations/tracing/vercelai/instrumentation.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { beforeEach, describe, expect, test } from 'vitest';
21
import { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_toolCallSpanContextMap } from '@sentry/core';
2+
import { beforeEach, describe, expect, test } from 'vitest';
33
import {
4+
checkResultForToolErrors,
45
determineRecordingSettings,
5-
_INTERNAL_checkResultForToolErrors,
66
} from '../../../../src/integrations/tracing/vercelai/instrumentation';
77

88
describe('determineRecordingSettings', () => {
@@ -226,7 +226,7 @@ describe('checkResultForToolErrors', () => {
226226
_INTERNAL_toolCallSpanContextMap.set('tool-1', { traceId: 't1', spanId: 's1' });
227227
_INTERNAL_toolCallSpanContextMap.set('tool-2', { traceId: 't2', spanId: 's2' });
228228

229-
_INTERNAL_checkResultForToolErrors({
229+
checkResultForToolErrors({
230230
content: [{ type: 'tool-result', toolCallId: 'tool-1', toolName: 'bash' }],
231231
});
232232

@@ -238,7 +238,7 @@ describe('checkResultForToolErrors', () => {
238238
test('cleans up span context map on tool-error', () => {
239239
_INTERNAL_toolCallSpanContextMap.set('tool-1', { traceId: 't1', spanId: 's1' });
240240

241-
_INTERNAL_checkResultForToolErrors({
241+
checkResultForToolErrors({
242242
content: [{ type: 'tool-error', toolCallId: 'tool-1', toolName: 'bash', error: new Error('fail') }],
243243
});
244244

@@ -249,7 +249,7 @@ describe('checkResultForToolErrors', () => {
249249
_INTERNAL_toolCallSpanContextMap.set('tool-1', { traceId: 't1', spanId: 's1' });
250250
_INTERNAL_toolCallSpanContextMap.set('tool-2', { traceId: 't2', spanId: 's2' });
251251

252-
_INTERNAL_checkResultForToolErrors({
252+
checkResultForToolErrors({
253253
content: [
254254
{ type: 'tool-result', toolCallId: 'tool-1', toolName: 'bash' },
255255
{ type: 'tool-error', toolCallId: 'tool-2', toolName: 'bash', error: new Error('fail') },
@@ -261,7 +261,7 @@ describe('checkResultForToolErrors', () => {
261261
});
262262

263263
test('does not throw for tool-error with unknown toolCallId', () => {
264-
_INTERNAL_checkResultForToolErrors({
264+
checkResultForToolErrors({
265265
content: [{ type: 'tool-error', toolCallId: 'unknown', toolName: 'bash', error: new Error('fail') }],
266266
});
267267

@@ -271,9 +271,9 @@ describe('checkResultForToolErrors', () => {
271271
test('ignores results without content array', () => {
272272
_INTERNAL_toolCallSpanContextMap.set('tool-1', { traceId: 't1', spanId: 's1' });
273273

274-
_INTERNAL_checkResultForToolErrors({});
275-
_INTERNAL_checkResultForToolErrors(null);
276-
_INTERNAL_checkResultForToolErrors({ content: 'not-an-array' });
274+
checkResultForToolErrors({});
275+
checkResultForToolErrors(null);
276+
checkResultForToolErrors({ content: 'not-an-array' });
277277

278278
// Map should be untouched
279279
expect(_INTERNAL_getSpanContextForToolCallId('tool-1')).toEqual({ traceId: 't1', spanId: 's1' });

0 commit comments

Comments
 (0)