69### Common configuration variables69### Common configuration variables
70 70
71| Environment Variable | Description | Example Values |71| Environment Variable | Description | Example Values |
72| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |72| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
73| `CLAUDE_CODE_ENABLE_TELEMETRY` | Enables telemetry collection (required) | `1` |73| `CLAUDE_CODE_ENABLE_TELEMETRY` | Enables telemetry collection (required) | `1` |
74| `OTEL_METRICS_EXPORTER` | Metrics exporter types, comma-separated. Use `none` to disable | `console`, `otlp`, `prometheus`, `none` |74| `OTEL_METRICS_EXPORTER` | Metrics exporter types, comma-separated. Use `none` to disable | `console`, `otlp`, `prometheus`, `none` |
75| `OTEL_LOGS_EXPORTER` | Logs/events exporter types, comma-separated. Use `none` to disable | `console`, `otlp`, `none` |75| `OTEL_LOGS_EXPORTER` | Logs/events exporter types, comma-separated. Use `none` to disable | `console`, `otlp`, `none` |
87| `OTEL_LOG_USER_PROMPTS` | Enable logging of user prompt content (default: disabled) | `1` to enable |87| `OTEL_LOG_USER_PROMPTS` | Enable logging of user prompt content (default: disabled) | `1` to enable |
88| `OTEL_LOG_TOOL_DETAILS` | Enable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, and tool input (default: disabled) | `1` to enable |88| `OTEL_LOG_TOOL_DETAILS` | Enable logging of tool parameters and input arguments in tool events and trace span attributes: Bash commands, MCP server and tool names, skill names, and tool input (default: disabled) | `1` to enable |
89| `OTEL_LOG_TOOL_CONTENT` | Enable logging of tool input and output content in span events (default: disabled). Requires [tracing](#traces-beta). Content is truncated at 60 KB | `1` to enable |89| `OTEL_LOG_TOOL_CONTENT` | Enable logging of tool input and output content in span events (default: disabled). Requires [tracing](#traces-beta). Content is truncated at 60 KB | `1` to enable |
90| `OTEL_LOG_RAW_API_BODIES` | Emit the full Anthropic Messages API request and response JSON as `api_request_body` / `api_response_body` log events (default: disabled). Bodies include the entire conversation history. Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal | `1` for inline bodies truncated at 60 KB, or `file:<dir>` for untruncated bodies on disk with a `body_ref` pointer in the event |
90| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | Metrics temporality preference (default: `delta`). Set to `cumulative` if your backend expects cumulative temporality | `delta`, `cumulative` |91| `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` | Metrics temporality preference (default: `delta`). Set to `cumulative` if your backend expects cumulative temporality | `delta`, `cumulative` |
91| `CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS` | Interval for refreshing dynamic headers (default: 1740000ms / 29 minutes) | `900000` |92| `CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS` | Interval for refreshing dynamic headers (default: 1740000ms / 29 minutes) | `900000` |
92 93
120 121
121When tracing is active, Bash and PowerShell subprocesses automatically inherit a `TRACEPARENT` environment variable containing the W3C trace context of the active tool execution span. This lets any subprocess that reads `TRACEPARENT` parent its own spans under the same trace, enabling end-to-end distributed tracing through scripts and commands that Claude runs.122When tracing is active, Bash and PowerShell subprocesses automatically inherit a `TRACEPARENT` environment variable containing the W3C trace context of the active tool execution span. This lets any subprocess that reads `TRACEPARENT` parent its own spans under the same trace, enabling end-to-end distributed tracing through scripts and commands that Claude runs.
122 123
124In Agent SDK and non-interactive sessions started with `-p`, Claude Code also reads `TRACEPARENT` and `TRACESTATE` from its own environment when starting each interaction span. This lets an embedding process pass its active W3C trace context into the subprocess so Claude Code's spans appear as children of the caller's distributed trace. Interactive sessions ignore inbound `TRACEPARENT` to avoid accidentally inheriting ambient values from CI or container environments.
125
126#### Span hierarchy
127
128Each user prompt starts a `claude_code.interaction` root span. API calls, tool calls, and hook executions are recorded as its children. Tool spans have two child spans of their own: one for the time spent waiting on a permission decision and one for the execution itself. When the Task tool spawns a subagent, the subagent's API and tool spans nest under the parent's `claude_code.tool` span.
129
130```text theme={null}
131claude_code.interaction
132├── claude_code.llm_request
133├── claude_code.hook (requires detailed beta tracing)
134└── claude_code.tool
135 ├── claude_code.tool.blocked_on_user
136 ├── claude_code.tool.execution
137 └── (Task tool) subagent claude_code.llm_request / claude_code.tool spans
138```
139
140In Agent SDK and `claude -p` sessions, `claude_code.interaction` itself becomes a child of the caller's span when `TRACEPARENT` is set in the environment.
141
142#### Span attributes
143
144Every span carries the [standard attributes](#standard-attributes) plus a `span.type` attribute matching its name. The tables below list the additional attributes set on each span. The `llm_request`, `tool.execution`, and `hook` spans set OpenTelemetry status `ERROR` when they record a failure; the other spans always end with status `UNSET`.
145
146**`claude_code.interaction`**
147
148| Attribute | Description | Gated by |
149| ------------------------- | --------------------------------------------------------- | ----------------------- |
150| `user_prompt` | Prompt text. Value is `<REDACTED>` unless the gate is set | `OTEL_LOG_USER_PROMPTS` |
151| `user_prompt_length` | Prompt length in characters | |
152| `interaction.sequence` | 1-based counter of interactions in this session | |
153| `interaction.duration_ms` | Wall-clock duration of the turn | |
154
155**`claude_code.llm_request`**
156
157| Attribute | Description | Gated by |
158| ------------------------ | -------------------------------------------------------------------------------- | -------- |
159| `model` | Model identifier | |
160| `gen_ai.system` | Always `anthropic`. OpenTelemetry GenAI semantic convention | |
161| `gen_ai.request.model` | Same value as `model`. OpenTelemetry GenAI semantic convention | |
162| `query_source` | Subsystem that issued the request, such as `repl_main_thread` or a subagent name | |
163| `speed` | `fast` or `normal` | |
164| `llm_request.context` | `interaction`, `tool`, or `standalone` depending on the parent span | |
165| `duration_ms` | Wall-clock duration including retries | |
166| `ttft_ms` | Time to first token in milliseconds | |
167| `input_tokens` | Input token count from the API usage block | |
168| `output_tokens` | Output token count | |
169| `cache_read_tokens` | Tokens read from prompt cache | |
170| `cache_creation_tokens` | Tokens written to prompt cache | |
171| `request_id` | Anthropic API request ID from the `request-id` response header | |
172| `gen_ai.response.id` | Same value as `request_id`. OpenTelemetry GenAI semantic convention | |
173| `client_request_id` | Client-generated `x-client-request-id` of the final attempt | |
174| `attempt` | Total attempts made for this request | |
175| `success` | `true` or `false` | |
176| `status_code` | HTTP status code when the request failed | |
177| `error` | Error message when the request failed | |
178| `response.has_tool_call` | `true` when the response contained tool-use blocks | |
179
180Each retry attempt is also recorded as a `gen_ai.request.attempt` span event with `attempt` and `client_request_id` attributes.
181
182**`claude_code.tool`**
183
184| Attribute | Description | Gated by |
185| --------------- | ----------------------------------------------------------- | ----------------------- |
186| `tool_name` | Tool name | |
187| `duration_ms` | Wall-clock duration including permission wait and execution | |
188| `result_tokens` | Approximate token size of the tool result | |
189| `file_path` | Target file path for Read, Edit, and Write tools | `OTEL_LOG_TOOL_DETAILS` |
190| `full_command` | Command string for the Bash tool | `OTEL_LOG_TOOL_DETAILS` |
191| `skill_name` | Skill name for the Skill tool | `OTEL_LOG_TOOL_DETAILS` |
192| `subagent_type` | Subagent type for the Task tool | `OTEL_LOG_TOOL_DETAILS` |
193
194When `OTEL_LOG_TOOL_CONTENT=1`, this span also records a `tool.output` span event whose attributes contain the tool's input and output bodies, truncated at 60 KB per attribute.
195
196**`claude_code.tool.blocked_on_user`**
197
198| Attribute | Description | Gated by |
199| ------------- | --------------------------------------------------- | -------- |
200| `duration_ms` | Time spent waiting for the permission decision | |
201| `decision` | `accept` or `reject` | |
202| `source` | Decision source, matching the `tool_decision` event | |
203
204**`claude_code.tool.execution`**
205
206| Attribute | Description | Gated by |
207| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
208| `duration_ms` | Time spent running the tool body | |
209| `success` | `true` or `false` | |
210| `error` | Error category string when execution failed, such as `Error:ENOENT` or `ShellError`. Contains the full error message instead when the gate is set | `OTEL_LOG_TOOL_DETAILS` |
211
212**`claude_code.hook`**
213
214This span is emitted only when detailed beta tracing is active, which requires `ENABLE_BETA_TRACING_DETAILED=1` and `BETA_TRACING_ENDPOINT` in addition to the trace exporter configuration above. In interactive CLI sessions, this also requires your organization to be allowlisted for the feature. Agent SDK and non-interactive `-p` sessions are not gated. It is not emitted when only `CLAUDE_CODE_ENHANCED_TELEMETRY_BETA` is set.
215
216| Attribute | Description | Gated by |
217| ------------------------ | ------------------------------------------------ | ----------------------- |
218| `hook_event` | Hook event type, such as `PreToolUse` | |
219| `hook_name` | Full hook name, such as `PreToolUse:Write` | |
220| `num_hooks` | Number of matching hook commands executed | |
221| `hook_definitions` | JSON-serialized hook configuration | `OTEL_LOG_TOOL_DETAILS` |
222| `duration_ms` | Wall-clock duration of all matching hooks | |
223| `num_success` | Count of hooks that completed successfully | |
224| `num_blocking` | Count of hooks that returned a blocking decision | |
225| `num_non_blocking_error` | Count of hooks that failed without blocking | |
226| `num_cancelled` | Count of hooks cancelled before completion | |
227
228<Note>
229 Additional content-bearing attributes such as `new_context`, `system_prompt_preview`, `tool_input`, and `response.model_output` are emitted only when detailed beta tracing is active. They are not part of the stable span schema.
230</Note>
231
123### Dynamic headers232### Dynamic headers
124 233
125For enterprise environments that require dynamic authentication, you can configure a script to generate headers dynamically:234For enterprise environments that require dynamic authentication, you can configure a script to generate headers dynamically:
286**Attributes**:395**Attributes**:
287 396
288* All [standard attributes](#standard-attributes)397* All [standard attributes](#standard-attributes)
398* `start_type`: How the session was started. One of `"fresh"`, `"resume"`, or `"continue"`
289 399
290#### Lines of code counter400#### Lines of code counter
291 401
320 430
321* All [standard attributes](#standard-attributes)431* All [standard attributes](#standard-attributes)
322* `model`: Model identifier (for example, "claude-sonnet-4-6")432* `model`: Model identifier (for example, "claude-sonnet-4-6")
433* `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"`
434* `speed`: `"fast"` when the request used fast mode. Absent otherwise
323 435
324#### Token counter436#### Token counter
325 437
330* All [standard attributes](#standard-attributes)442* All [standard attributes](#standard-attributes)
331* `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`)443* `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`)
332* `model`: Model identifier (for example, "claude-sonnet-4-6")444* `model`: Model identifier (for example, "claude-sonnet-4-6")
445* `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"`
446* `speed`: `"fast"` when the request used fast mode. Absent otherwise
333 447
334#### Code edit tool decision counter448#### Code edit tool decision counter
335 449
400* `tool_name`: Name of the tool514* `tool_name`: Name of the tool
401* `success`: `"true"` or `"false"`515* `success`: `"true"` or `"false"`
402* `duration_ms`: Execution time in milliseconds516* `duration_ms`: Execution time in milliseconds
403* `error`: Error message (if failed)517* `error_type`: Error category string when the tool failed, such as `"Error:ENOENT"` or `"ShellError"`
518* `error` (when `OTEL_LOG_TOOL_DETAILS=1`): Full error message when the tool failed
404* `decision_type`: Either `"accept"` or `"reject"`519* `decision_type`: Either `"accept"` or `"reject"`
405* `decision_source`: Decision source - `"config"`, `"hook"`, `"user_permanent"`, `"user_temporary"`, `"user_abort"`, or `"user_reject"`520* `decision_source`: Decision source - `"config"`, `"hook"`, `"user_permanent"`, `"user_temporary"`, `"user_abort"`, or `"user_reject"`
406* `tool_result_size_bytes`: Size of the tool result in bytes521* `tool_result_size_bytes`: Size of the tool result in bytes
409 * For Bash tool: includes `bash_command`, `full_command`, `timeout`, `description`, `dangerouslyDisableSandbox`, and `git_commit_id` (the commit SHA, when a `git commit` command succeeds)524 * For Bash tool: includes `bash_command`, `full_command`, `timeout`, `description`, `dangerouslyDisableSandbox`, and `git_commit_id` (the commit SHA, when a `git commit` command succeeds)
410 * For MCP tools: includes `mcp_server_name`, `mcp_tool_name`525 * For MCP tools: includes `mcp_server_name`, `mcp_tool_name`
411 * For Skill tool: includes `skill_name`526 * For Skill tool: includes `skill_name`
527 * For Task tool: includes `subagent_type`
412* `tool_input` (when `OTEL_LOG_TOOL_DETAILS=1`): JSON-serialized tool arguments. Individual values over 512 characters are truncated, and the full payload is bounded to \~4 K characters. Applies to all tools including MCP tools.528* `tool_input` (when `OTEL_LOG_TOOL_DETAILS=1`): JSON-serialized tool arguments. Individual values over 512 characters are truncated, and the full payload is bounded to \~4 K characters. Applies to all tools including MCP tools.
413 529
414#### API request event530#### API request event
430* `output_tokens`: Number of output tokens546* `output_tokens`: Number of output tokens
431* `cache_read_tokens`: Number of tokens read from cache547* `cache_read_tokens`: Number of tokens read from cache
432* `cache_creation_tokens`: Number of tokens used for cache creation548* `cache_creation_tokens`: Number of tokens used for cache creation
549* `request_id`: Anthropic API request ID from the response's `request-id` header, such as `"req_011..."`. Present only when the API returns one.
433* `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active550* `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active
551* `query_source`: Subsystem that issued the request, such as `"repl_main_thread"`, `"compact"`, or a subagent name
434 552
435#### API error event553#### API error event
436 554
449* `status_code`: HTTP status code as a string, or `"undefined"` for non-HTTP errors567* `status_code`: HTTP status code as a string, or `"undefined"` for non-HTTP errors
450* `duration_ms`: Request duration in milliseconds568* `duration_ms`: Request duration in milliseconds
451* `attempt`: Total number of attempts made, including the initial request (`1` means no retries occurred)569* `attempt`: Total number of attempts made, including the initial request (`1` means no retries occurred)
570* `request_id`: Anthropic API request ID from the response's `request-id` header, such as `"req_011..."`. Present only when the API returns one.
452* `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active571* `speed`: `"fast"` or `"normal"`, indicating whether fast mode was active
572* `query_source`: Subsystem that issued the request, such as `"repl_main_thread"`, `"compact"`, or a subagent name
573
574#### API request body event
575
576Logged for each API request attempt when `OTEL_LOG_RAW_API_BODIES` is set. One event is emitted per attempt, so retries with adjusted parameters each produce their own event.
577
578**Event Name**: `claude_code.api_request_body`
579
580**Attributes**:
581
582* All [standard attributes](#standard-attributes)
583* `event.name`: `"api_request_body"`
584* `event.timestamp`: ISO 8601 timestamp
585* `event.sequence`: monotonically increasing counter for ordering events within a session
586* `body`: JSON-serialized Messages API request parameters (system prompt, messages, tools, etc.), truncated at 60 KB. Extended-thinking content in prior assistant turns is redacted. Emitted only in inline mode (`OTEL_LOG_RAW_API_BODIES=1`).
587* `body_ref`: Absolute path to a `<dir>/<uuid>.request.json` file containing the untruncated body. Emitted only in file mode (`OTEL_LOG_RAW_API_BODIES=file:<dir>`).
588* `body_length`: Untruncated body length. UTF-8 bytes when `OTEL_LOG_RAW_API_BODIES=file:<dir>`, or UTF-16 code units when `=1`
589* `body_truncated`: `"true"` when inline truncation occurred. Absent in file mode and when no truncation occurred.
590* `model`: Model identifier from the request parameters
591* `query_source`: Subsystem that issued the request (for example, `"compact"`)
592
593#### API response body event
594
595Logged for each successful API response when `OTEL_LOG_RAW_API_BODIES` is set.
596
597**Event Name**: `claude_code.api_response_body`
598
599**Attributes**:
600
601* All [standard attributes](#standard-attributes)
602* `event.name`: `"api_response_body"`
603* `event.timestamp`: ISO 8601 timestamp
604* `event.sequence`: monotonically increasing counter for ordering events within a session
605* `body`: JSON-serialized Messages API response (id, content blocks, usage, stop reason), truncated at 60 KB. Extended-thinking content is redacted. Emitted only in inline mode (`OTEL_LOG_RAW_API_BODIES=1`).
606* `body_ref`: Absolute path to a `<dir>/<request_id>.response.json` file containing the untruncated body. Emitted only in file mode (`OTEL_LOG_RAW_API_BODIES=file:<dir>`).
607* `body_length`: Untruncated body length. UTF-8 bytes when `OTEL_LOG_RAW_API_BODIES=file:<dir>`, or UTF-16 code units when `=1`
608* `body_truncated`: `"true"` when inline truncation occurred. Absent in file mode and when no truncation occurred.
609* `model`: Model identifier
610* `query_source`: Subsystem that issued the request
611* `request_id`: Anthropic API request ID from the response's `request-id` header, such as `"req_011..."`. Present only when the API returns one.
453 612
454#### Tool decision event613#### Tool decision event
455 614
467* `decision`: Either `"accept"` or `"reject"`626* `decision`: Either `"accept"` or `"reject"`
468* `source`: Decision source - `"config"`, `"hook"`, `"user_permanent"`, `"user_temporary"`, `"user_abort"`, or `"user_reject"`627* `source`: Decision source - `"config"`, `"hook"`, `"user_permanent"`, `"user_temporary"`, `"user_abort"`, or `"user_reject"`
469 628
629#### Permission mode changed event
630
631Logged when the permission mode changes, for example from `Shift+Tab` cycling, exiting plan mode, or an auto mode gate check.
632
633**Event Name**: `claude_code.permission_mode_changed`
634
635**Attributes**:
636
637* All [standard attributes](#standard-attributes)
638* `event.name`: `"permission_mode_changed"`
639* `event.timestamp`: ISO 8601 timestamp
640* `event.sequence`: monotonically increasing counter for ordering events within a session
641* `from_mode`: The previous permission mode, for example `"default"`, `"plan"`, `"acceptEdits"`, `"auto"`, or `"bypassPermissions"`
642* `to_mode`: The new permission mode
643* `trigger`: What caused the change. One of `"shift_tab"`, `"exit_plan_mode"`, `"auto_gate_denied"`, or `"auto_opt_in"`. Absent when the transition originates from the SDK or bridge
644
645#### Auth event
646
647Logged when `/login` or `/logout` completes.
648
649**Event Name**: `claude_code.auth`
650
651**Attributes**:
652
653* All [standard attributes](#standard-attributes)
654* `event.name`: `"auth"`
655* `event.timestamp`: ISO 8601 timestamp
656* `event.sequence`: monotonically increasing counter for ordering events within a session
657* `action`: `"login"` or `"logout"`
658* `success`: `"true"` or `"false"`
659* `auth_method`: Authentication method, such as `"oauth"`
660* `error_category`: Categorical error kind when the action failed. The raw error message is never included
661* `status_code`: HTTP status code as a string when the action failed with an HTTP error
662
663#### MCP server connection event
664
665Logged when an MCP server connects, disconnects, or fails to connect.
666
667**Event Name**: `claude_code.mcp_server_connection`
668
669**Attributes**:
670
671* All [standard attributes](#standard-attributes)
672* `event.name`: `"mcp_server_connection"`
673* `event.timestamp`: ISO 8601 timestamp
674* `event.sequence`: monotonically increasing counter for ordering events within a session
675* `status`: `"connected"`, `"failed"`, or `"disconnected"`
676* `transport_type`: Server transport, such as `"stdio"`, `"sse"`, or `"http"`
677* `server_scope`: Scope the server is configured at, such as `"user"`, `"project"`, or `"local"`
678* `duration_ms`: Connection attempt duration in milliseconds
679* `error_code`: Error code when the connection failed
680* `server_name` (when `OTEL_LOG_TOOL_DETAILS=1`): Configured server name
681* `error` (when `OTEL_LOG_TOOL_DETAILS=1`): Full error message when the connection failed
682
683#### Internal error event
684
685Logged when Claude Code catches an unexpected internal error. Only the error class name and an errno-style code are recorded. The error message and stack trace are never included. This event is not emitted when running against Bedrock, Vertex, or Foundry, or when `DISABLE_ERROR_REPORTING` is set.
686
687**Event Name**: `claude_code.internal_error`
688
689**Attributes**:
690
691* All [standard attributes](#standard-attributes)
692* `event.name`: `"internal_error"`
693* `event.timestamp`: ISO 8601 timestamp
694* `event.sequence`: monotonically increasing counter for ordering events within a session
695* `error_name`: Error class name, such as `"TypeError"` or `"SyntaxError"`
696* `error_code`: Node.js errno code such as `"ENOENT"` when present on the error
697
470#### Plugin installed event698#### Plugin installed event
471 699
472Logged when a plugin finishes installing, from both the `claude plugin install` CLI command and the interactive `/plugin` UI.700Logged when a plugin finishes installing, from both the `claude plugin install` CLI command and the interactive `/plugin` UI.
479* `event.name`: `"plugin_installed"`707* `event.name`: `"plugin_installed"`
480* `event.timestamp`: ISO 8601 timestamp708* `event.timestamp`: ISO 8601 timestamp
481* `event.sequence`: monotonically increasing counter for ordering events within a session709* `event.sequence`: monotonically increasing counter for ordering events within a session
482* `plugin.name`: Name of the installed plugin
483* `plugin.version`: Plugin version when declared in the marketplace entry
484* `marketplace.name`: Marketplace the plugin was installed from
485* `marketplace.is_official`: `"true"` if the marketplace is an official Anthropic marketplace, `"false"` otherwise710* `marketplace.is_official`: `"true"` if the marketplace is an official Anthropic marketplace, `"false"` otherwise
486* `install.trigger`: `"cli"` or `"ui"`711* `install.trigger`: `"cli"` or `"ui"`
712* `plugin.name`: Name of the installed plugin. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1`
713* `plugin.version`: Plugin version when declared in the marketplace entry. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1`
714* `marketplace.name`: Marketplace the plugin was installed from. For third-party marketplaces this is included only when `OTEL_LOG_TOOL_DETAILS=1`
487 715
488#### Skill activated event716#### Skill activated event
489 717
497* `event.name`: `"skill_activated"`725* `event.name`: `"skill_activated"`
498* `event.timestamp`: ISO 8601 timestamp726* `event.timestamp`: ISO 8601 timestamp
499* `event.sequence`: monotonically increasing counter for ordering events within a session727* `event.sequence`: monotonically increasing counter for ordering events within a session
500* `skill.name`: Name of the skill728* `skill.name`: Name of the skill. For user-defined and third-party plugin skills the value is the placeholder `"custom_skill"` unless `OTEL_LOG_TOOL_DETAILS=1`
501* `skill.source`: Where the skill was loaded from (for example, `"bundled"`, `"userSettings"`, `"projectSettings"`, `"plugin"`)729* `skill.source`: Where the skill was loaded from (for example, `"bundled"`, `"userSettings"`, `"projectSettings"`, `"plugin"`)
502* `plugin.name`: Name of the owning plugin when the skill is provided by a plugin730* `plugin.name` (when `OTEL_LOG_TOOL_DETAILS=1` or the plugin is from an official marketplace): Name of the owning plugin when the skill is provided by a plugin
503* `marketplace.name`: Marketplace the owning plugin was installed from, when the skill is provided by a plugin731* `marketplace.name` (when `OTEL_LOG_TOOL_DETAILS=1` or the plugin is from an official marketplace): Marketplace the owning plugin was installed from, when the skill is provided by a plugin
732
733#### API retries exhausted event
734
735Logged once when an API request fails after more than one attempt. Emitted alongside the final `api_error` event.
736
737**Event Name**: `claude_code.api_retries_exhausted`
738
739**Attributes**:
740
741* All [standard attributes](#standard-attributes)
742* `event.name`: `"api_retries_exhausted"`
743* `event.timestamp`: ISO 8601 timestamp
744* `event.sequence`: monotonically increasing counter for ordering events within a session
745* `model`: Model used
746* `error`: Final error message
747* `status_code`: HTTP status code as a string
748* `total_attempts`: Total number of attempts made
749* `total_retry_duration_ms`: Total wall-clock time across all attempts
750* `speed`: `"fast"` or `"normal"`
751
752#### Hook execution start event
753
754Logged when one or more hooks begin executing for a hook event.
755
756**Event Name**: `claude_code.hook_execution_start`
757
758**Attributes**:
759
760* All [standard attributes](#standard-attributes)
761* `event.name`: `"hook_execution_start"`
762* `event.timestamp`: ISO 8601 timestamp
763* `event.sequence`: monotonically increasing counter for ordering events within a session
764* `hook_event`: Hook event type, such as `"PreToolUse"` or `"PostToolUse"`
765* `hook_name`: Full hook name including matcher, such as `"PreToolUse:Write"`
766* `num_hooks`: Number of matching hook commands
767* `managed_only`: `"true"` when only managed-policy hooks are permitted
768* `hook_source`: `"policySettings"` or `"merged"`
769* `hook_definitions`: JSON-serialized hook configuration. Included only when both detailed beta tracing and `OTEL_LOG_TOOL_DETAILS=1` are enabled
770
771#### Hook execution complete event
772
773Logged when all hooks for a hook event have finished.
774
775**Event Name**: `claude_code.hook_execution_complete`
776
777**Attributes**:
778
779* All [standard attributes](#standard-attributes)
780* `event.name`: `"hook_execution_complete"`
781* `event.timestamp`: ISO 8601 timestamp
782* `event.sequence`: monotonically increasing counter for ordering events within a session
783* `hook_event`: Hook event type
784* `hook_name`: Full hook name including matcher
785* `num_hooks`: Number of matching hook commands
786* `num_success`: Count that completed successfully
787* `num_blocking`: Count that returned a blocking decision
788* `num_non_blocking_error`: Count that failed without blocking
789* `num_cancelled`: Count cancelled before completion
790* `total_duration_ms`: Wall-clock duration of all matching hooks
791* `managed_only`: `"true"` when only managed-policy hooks are permitted
792* `hook_source`: `"policySettings"` or `"merged"`
793* `hook_definitions`: JSON-serialized hook configuration. Included only when both detailed beta tracing and `OTEL_LOG_TOOL_DETAILS=1` are enabled
794
795#### Compaction event
796
797Logged when conversation compaction completes.
798
799**Event Name**: `claude_code.compaction`
800
801**Attributes**:
802
803* All [standard attributes](#standard-attributes)
804* `event.name`: `"compaction"`
805* `event.timestamp`: ISO 8601 timestamp
806* `event.sequence`: monotonically increasing counter for ordering events within a session
807* `trigger`: `"auto"` or `"manual"`
808* `success`: `"true"` or `"false"`
809* `duration_ms`: Compaction duration
810* `pre_tokens`: Approximate token count before compaction
811* `post_tokens`: Approximate token count after compaction
812* `error`: Error message when compaction failed
504 813
505## Interpret metrics and events data814## Interpret metrics and events data
506 815
606* User prompt content is not collected by default. Only prompt length is recorded. To include prompt content, set `OTEL_LOG_USER_PROMPTS=1`915* User prompt content is not collected by default. Only prompt length is recorded. To include prompt content, set `OTEL_LOG_USER_PROMPTS=1`
607* Tool input arguments and parameters are not logged by default. To include them, set `OTEL_LOG_TOOL_DETAILS=1`. When enabled, `tool_result` events include a `tool_parameters` attribute with Bash commands, MCP server and tool names, and skill names, plus a `tool_input` attribute with file paths, URLs, search patterns, and other arguments. Trace spans include the same `tool_input` attribute and input-derived attributes such as `file_path`. Individual values over 512 characters are truncated and the total is bounded to \~4 K characters, but the arguments may still contain sensitive values. Configure your telemetry backend to filter or redact these attributes as needed916* Tool input arguments and parameters are not logged by default. To include them, set `OTEL_LOG_TOOL_DETAILS=1`. When enabled, `tool_result` events include a `tool_parameters` attribute with Bash commands, MCP server and tool names, and skill names, plus a `tool_input` attribute with file paths, URLs, search patterns, and other arguments. Trace spans include the same `tool_input` attribute and input-derived attributes such as `file_path`. Individual values over 512 characters are truncated and the total is bounded to \~4 K characters, but the arguments may still contain sensitive values. Configure your telemetry backend to filter or redact these attributes as needed
608* Tool input and output content is not logged in trace spans by default. To include it, set `OTEL_LOG_TOOL_CONTENT=1`. When enabled, span events include full tool input and output content truncated at 60 KB per span. This can include raw file contents from Read tool results and Bash command output. Configure your telemetry backend to filter or redact these attributes as needed917* Tool input and output content is not logged in trace spans by default. To include it, set `OTEL_LOG_TOOL_CONTENT=1`. When enabled, span events include full tool input and output content truncated at 60 KB per span. This can include raw file contents from Read tool results and Bash command output. Configure your telemetry backend to filter or redact these attributes as needed
918* Raw Anthropic Messages API request and response bodies are not logged by default. To include them, set `OTEL_LOG_RAW_API_BODIES`. With `=1`, each API call emits `api_request_body` and `api_response_body` log events whose `body` attribute is the JSON-serialized payload, truncated at 60 KB. With `=file:<dir>`, untruncated bodies are written to `.request.json` and `.response.json` files under that directory and the events carry a `body_ref` path instead of the inline body. Ship the directory with a log collector or sidecar rather than through the telemetry stream. In both modes, bodies contain the full conversation history (system prompt, every prior user and assistant turn, tool results), so enabling this implies consent to everything the other `OTEL_LOG_*` content flags would reveal. Claude's extended-thinking content is always redacted from these bodies regardless of other settings
609 919
610## Monitor Claude Code on Amazon Bedrock920## Monitor Claude Code on Amazon Bedrock
611 921