Skip to content

Commit 3f69bfd

Browse files
committed
feat(node): Enhance Claude Code instrumentation with OpenTelemetry spec compliance
- Fix GEN_AI_SYSTEM_ATTRIBUTE to use 'anthropic' per OpenTelemetry semantic conventions - Add GEN_AI_REQUEST_AVAILABLE_TOOLS_ATTRIBUTE for capturing available tools from system init - Add GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE for tracking stop_reason - Use getTruncatedJsonString for proper payload truncation in span attributes - Expand tool categorization with new tools (KillBash, EnterPlanMode, AskUserQuestion, Skill, MCP tools) - Add better error metadata with function name in mechanism data - Export patchClaudeCodeQuery for manual instrumentation use cases - Add comprehensive integration tests for Claude Code Agent SDK instrumentation
1 parent a5b8330 commit 3f69bfd

17 files changed

Lines changed: 1444 additions & 269 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
// Configuration with custom options that override sendDefaultPii
5+
// sendDefaultPii: false, but recordInputs: true, recordOutputs: false
6+
// This means input messages SHOULD be recorded, but NOT output text
7+
8+
Sentry.init({
9+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
10+
release: '1.0',
11+
tracesSampleRate: 1.0,
12+
sendDefaultPii: false,
13+
transport: loggingTransport,
14+
integrations: [
15+
Sentry.claudeCodeAgentSdkIntegration({
16+
recordInputs: true,
17+
recordOutputs: false,
18+
}),
19+
],
20+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
// Configuration with PII enabled
5+
// This means input messages and output text SHOULD be recorded
6+
7+
Sentry.init({
8+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
9+
release: '1.0',
10+
tracesSampleRate: 1.0,
11+
sendDefaultPii: true,
12+
transport: loggingTransport,
13+
integrations: [Sentry.claudeCodeAgentSdkIntegration()],
14+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
// Default configuration: sendDefaultPii: false
5+
// This means NO input messages or output text should be recorded by default
6+
7+
Sentry.init({
8+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
9+
release: '1.0',
10+
tracesSampleRate: 1.0,
11+
sendDefaultPii: false,
12+
transport: loggingTransport,
13+
integrations: [Sentry.claudeCodeAgentSdkIntegration()],
14+
});

0 commit comments

Comments
 (0)