Skip to content

Commit 17a2f1e

Browse files
committed
fix names
1 parent 44e4347 commit 17a2f1e

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

packages/core/src/utils/ai/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
* Maps AI method paths to Sentry operation name
1212
*/
1313
export function getFinalOperationName(methodPath: string): string {
14-
return `gen_ai.${methodPath.split('.').pop() || 'unknown'}`;
14+
return methodPath.split('.').pop() || 'unknown';
1515
}
1616

1717
/**

packages/core/src/utils/anthropic-ai/constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export const ANTHROPIC_AI_INTEGRATION_NAME = 'Anthropic_AI';
33
// https://docs.anthropic.com/en/api/messages
44
// https://docs.anthropic.com/en/api/models-list
55
export const ANTHROPIC_AI_INSTRUMENTED_METHODS = [
6-
'anthropic.messages.create',
7-
'anthropic.messages.countTokens',
8-
'anthropic.models.list',
9-
'anthropic.models.get',
10-
'anthropic.completions.create',
6+
'messages.create',
7+
'messages.countTokens',
8+
'models.list',
9+
'models.get',
10+
'completions.create',
1111
] as const;

packages/core/src/utils/anthropic-ai/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ function addResponseAttributes(span: Span, response: AnthropicAiResponse, record
9898
span.setAttributes({
9999
[GEN_AI_RESPONSE_MODEL_ATTRIBUTE]: response.model,
100100
});
101-
span.setAttributes({
102-
[ANTHROPIC_AI_RESPONSE_TIMESTAMP_ATTRIBUTE]: new Date(response.created * 1000).toISOString(),
103-
});
101+
if ('created' in response && typeof response.created === 'number') {
102+
span.setAttributes({
103+
[ANTHROPIC_AI_RESPONSE_TIMESTAMP_ATTRIBUTE]: new Date(response.created * 1000).toISOString(),
104+
});
105+
}
104106

105107
if (response.usage) {
106108
setTokenUsageAttributes(
@@ -178,8 +180,6 @@ function createDeepProxy<T extends AnthropicAiClient>(target: T, currentPath = '
178180
get(obj: object, prop: string): unknown {
179181
const value = (obj as Record<string, unknown>)[prop];
180182
const methodPath = buildMethodPath(currentPath, String(prop));
181-
// eslint-disable-next-line no-console
182-
console.log('value ----->>>>', value);
183183

184184
if (typeof value === 'function' && shouldInstrument(methodPath)) {
185185
return instrumentMethod(value as (...args: unknown[]) => Promise<unknown>, methodPath, obj, options);

packages/node/src/integrations/tracing/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Integration } from '@sentry/core';
22
import { instrumentOtelHttp } from '../http';
33
import { amqplibIntegration, instrumentAmqplib } from './amqplib';
4-
import { anthropicAIIntegration } from './anthropic-ai';
4+
import { anthropicAIIntegration, instrumentAnthropicAi } from './anthropic-ai';
55
import { connectIntegration, instrumentConnect } from './connect';
66
import { expressIntegration, instrumentExpress } from './express';
77
import { fastifyIntegration, instrumentFastify, instrumentFastifyV3 } from './fastify';
@@ -85,5 +85,6 @@ export function getOpenTelemetryInstrumentationToPreload(): (((options?: any) =>
8585
instrumentOpenAi,
8686
instrumentPostgresJs,
8787
instrumentFirebase,
88+
instrumentAnthropicAi,
8889
];
8990
}

0 commit comments

Comments
 (0)