|
1 | 1 | import { getCurrentScope } from '../../currentScopes';
|
2 | 2 | import { captureException } from '../../exports';
|
| 3 | +import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../semanticAttributes'; |
3 | 4 | import { startSpan } from '../../tracing/trace';
|
4 | 5 | import type { Span, SpanAttributeValue } from '../../types-hoist/span';
|
5 | 6 | import {
|
@@ -28,14 +29,14 @@ import type {
|
28 | 29 | AnthropicAiResponse,
|
29 | 30 | } from './types';
|
30 | 31 | import { shouldInstrument } from './utils';
|
31 |
| - |
32 | 32 | /**
|
33 | 33 | * Extract request attributes from method arguments
|
34 | 34 | */
|
35 | 35 | function extractRequestAttributes(args: unknown[], methodPath: string): Record<string, unknown> {
|
36 | 36 | const attributes: Record<string, unknown> = {
|
37 | 37 | [GEN_AI_SYSTEM_ATTRIBUTE]: 'anthropic',
|
38 | 38 | [GEN_AI_OPERATION_NAME_ATTRIBUTE]: getFinalOperationName(methodPath),
|
| 39 | + [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ai.anthropic', |
39 | 40 | };
|
40 | 41 |
|
41 | 42 | if (args.length > 0 && typeof args[0] === 'object' && args[0] !== null) {
|
@@ -168,7 +169,15 @@ function instrumentMethod<T extends unknown[], R>(
|
168 | 169 | addResponseAttributes(span, result, finalOptions.recordOutputs);
|
169 | 170 | return result;
|
170 | 171 | } catch (error) {
|
171 |
| - captureException(error); |
| 172 | + captureException(error, { |
| 173 | + mechanism: { |
| 174 | + handled: false, |
| 175 | + }, |
| 176 | + type: 'auto.ai.anthropic', |
| 177 | + data: { |
| 178 | + function: methodPath, |
| 179 | + }, |
| 180 | + }); |
172 | 181 | throw error;
|
173 | 182 | }
|
174 | 183 | },
|
|
0 commit comments