Skip to content

Commit 82d683c

Browse files
committed
some renames
1 parent 60d9f62 commit 82d683c

6 files changed

Lines changed: 15 additions & 15 deletions

File tree

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export * as metrics from './metrics/public-api';
146146
export type { MetricOptions } from './metrics/public-api';
147147
export { createConsolaReporter } from './integrations/consola';
148148
export { addVercelAiProcessors } from './tracing/vercel-ai';
149-
export { _INTERNAL_getSpanForToolCallId, _INTERNAL_cleanupToolCallSpan } from './tracing/vercel-ai/utils';
149+
export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpan } from './tracing/vercel-ai/utils';
150150
export { instrumentOpenAiClient } from './tracing/openai';
151151
export { OPENAI_INTEGRATION_NAME } from './tracing/openai/constants';
152152
export { instrumentAnthropicAiClient } from './tracing/anthropic-ai';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ToolCallSpanContext } from './types';
33
// Global map to track tool call IDs to their corresponding span contexts.
44
// This allows us to capture tool errors and link them to the correct span
55
// without keeping full Span objects (and their potentially large attributes) alive.
6-
export const toolCallSpanMap = new Map<string, ToolCallSpanContext>();
6+
export const toolCallSpanContextMap = new Map<string, ToolCallSpanContext>();
77

88
// Operation sets for efficient mapping to OpenTelemetry semantic convention values
99
export const INVOKE_AGENT_OPS = new Set([

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ 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, toolCallSpanMap } from './constants';
22+
import { EMBEDDINGS_OPS, GENERATE_CONTENT_OPS, INVOKE_AGENT_OPS, RERANK_OPS, toolCallSpanContextMap } from './constants';
2323
import type { TokenSummary } from './types';
2424
import {
2525
accumulateTokensForParent,
@@ -238,7 +238,7 @@ function processToolCallSpan(span: Span, attributes: SpanAttributes): void {
238238
const toolCallId = attributes[GEN_AI_TOOL_CALL_ID_ATTRIBUTE];
239239

240240
if (typeof toolCallId === 'string') {
241-
toolCallSpanMap.set(toolCallId, span.spanContext());
241+
toolCallSpanContextMap.set(toolCallId, span.spanContext());
242242
}
243243

244244
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-tool-type

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE,
1818
} from '../ai/gen-ai-attributes';
1919
import { extractSystemInstructions, getTruncatedJsonString } from '../ai/utils';
20-
import { toolCallSpanMap } from './constants';
20+
import { toolCallSpanContextMap } from './constants';
2121
import type { TokenSummary, ToolCallSpanContext } from './types';
2222
import { AI_PROMPT_ATTRIBUTE, AI_PROMPT_MESSAGES_ATTRIBUTE } from './vercel-ai-attributes';
2323

@@ -77,15 +77,15 @@ export function applyAccumulatedTokens(
7777
/**
7878
* Get the span context associated with a tool call ID.
7979
*/
80-
export function _INTERNAL_getSpanForToolCallId(toolCallId: string): ToolCallSpanContext | undefined {
81-
return toolCallSpanMap.get(toolCallId);
80+
export function _INTERNAL_getSpanContextForToolCallId(toolCallId: string): ToolCallSpanContext | undefined {
81+
return toolCallSpanContextMap.get(toolCallId);
8282
}
8383

8484
/**
8585
* Clean up the span mapping for a tool call ID
8686
*/
8787
export function _INTERNAL_cleanupToolCallSpan(toolCallId: string): void {
88-
toolCallSpanMap.delete(toolCallId);
88+
toolCallSpanContextMap.delete(toolCallId);
8989
}
9090

9191
/**

packages/core/test/lib/tracing/vercel-ai-tool-call-span-map.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it } from 'vitest';
22
import { addVercelAiProcessors } from '../../../src/tracing/vercel-ai';
3-
import { toolCallSpanMap } from '../../../src/tracing/vercel-ai/constants';
4-
import { _INTERNAL_cleanupToolCallSpan, _INTERNAL_getSpanForToolCallId } from '../../../src/tracing/vercel-ai/utils';
3+
import { toolCallSpanContextMap } from '../../../src/tracing/vercel-ai/constants';
4+
import { _INTERNAL_cleanupToolCallSpan, _INTERNAL_getSpanContextForToolCallId } from '../../../src/tracing/vercel-ai/utils';
55
import {
66
AI_TOOL_CALL_ID_ATTRIBUTE,
77
AI_TOOL_CALL_NAME_ATTRIBUTE,
@@ -79,7 +79,7 @@ function createToolCallSpan(params: {
7979

8080
describe('vercel-ai tool call span context map', () => {
8181
beforeEach(() => {
82-
toolCallSpanMap.clear();
82+
toolCallSpanContextMap.clear();
8383
});
8484

8585
it('stores toolCallId -> span context on spanStart', () => {
@@ -97,12 +97,12 @@ describe('vercel-ai tool call span context map', () => {
9797

9898
client.emit('spanStart', span);
9999

100-
expect(_INTERNAL_getSpanForToolCallId('tool-call-1')).toMatchObject({
100+
expect(_INTERNAL_getSpanContextForToolCallId('tool-call-1')).toMatchObject({
101101
traceId: 'trace-id-1',
102102
spanId: 'span-id-1',
103103
});
104104

105105
_INTERNAL_cleanupToolCallSpan('tool-call-1');
106-
expect(_INTERNAL_getSpanForToolCallId('tool-call-1')).toBeUndefined();
106+
expect(_INTERNAL_getSpanContextForToolCallId('tool-call-1')).toBeUndefined();
107107
});
108108
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { InstrumentationConfig, InstrumentationModuleDefinition } from '@op
22
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
33
import {
44
_INTERNAL_cleanupToolCallSpan,
5-
_INTERNAL_getSpanForToolCallId,
5+
_INTERNAL_getSpanContextForToolCallId,
66
addNonEnumerableProperty,
77
captureException,
88
getActiveSpan,
@@ -108,7 +108,7 @@ function checkResultForToolErrors(result: unknown): void {
108108
}
109109

110110
// Try to get the span context associated with this tool call ID
111-
const spanContext = _INTERNAL_getSpanForToolCallId(item.toolCallId);
111+
const spanContext = _INTERNAL_getSpanContextForToolCallId(item.toolCallId);
112112

113113
if (spanContext) {
114114
// We have a span context, so link the error using span and trace IDs from the span

0 commit comments

Comments
 (0)