Skip to content

Commit 6a847b6

Browse files
committed
update op name
1 parent 17a2f1e commit 6a847b6

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ import {
1111
* Maps AI method paths to Sentry operation name
1212
*/
1313
export function getFinalOperationName(methodPath: string): string {
14+
if (methodPath.includes('messages.create')) {
15+
return 'messages.create';
16+
}
17+
if (methodPath.includes('messages.countTokens')) {
18+
return 'messages.countTokens';
19+
}
20+
if (methodPath.includes('completions.create')) {
21+
return 'completions.create';
22+
}
23+
if (methodPath.includes('models.list')) {
24+
return 'models.list';
25+
}
26+
if (methodPath.includes('models.get')) {
27+
return 'models.get';
28+
}
1429
return methodPath.split('.').pop() || 'unknown';
1530
}
1631

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ function addResponseAttributes(span: Span, response: AnthropicAiResponse, record
8080
if (recordOutputs) {
8181
// Messages.create
8282
if ('content' in response) {
83-
span.setAttributes({ [GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content });
83+
if (Array.isArray(response.content)) {
84+
span.setAttributes({
85+
[GEN_AI_RESPONSE_TEXT_ATTRIBUTE]: response.content.map((item: { text: string }) => item.text).join(''),
86+
});
87+
}
8488
}
8589
// Completions.create
8690
if ('completion' in response) {

packages/node/src/integrations/tracing/anthropic-ai/instrumentation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export class SentryAnthropicAiInstrumentation extends InstrumentationBase<Instru
5858
*/
5959
private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {
6060
const Original = exports.Anthropic;
61-
// eslint-disable-next-line no-console
62-
console.log('Original ----->>>>', Original);
6361

6462
const WrappedAnthropic = function (this: unknown, ...args: unknown[]) {
6563
const instance = Reflect.construct(Original, args);

0 commit comments

Comments
 (0)