Claude Code OpenTelemetry Reference - Every Metric and Event, Their Attributes, and What Each Lets You Audit

First Published:
Last Updated:

When configured with CLAUDE_CODE_ENABLE_TELEMETRY=1 and an exporter, Claude Code sends metrics and events via OpenTelemetry (OTel). Enabling beta tracing also sends spans. The data is sent to collectors or SIEM systems provided by the organization. However, enabling OTel does not make everything visible. The body of prompts, tool arguments, and the names of MCP servers configured by users are redacted by default. While administrators can pin the destination and credentials, developers can set the exporter to none unless the exporter is also set in managed settings. The claude_code.safety_event still has its own section on the monitoring page, but is no longer sent as of v2.1.312.

This article lists the eight types of metrics, twenty-eight types of events, and six types of spans that the monitoring page documents, allowing you to identify them by name. For each, it describes what is included by default, what requires explicit opt-in, who can pin it, and which audit questions it can help answer. It also notes questions that cannot currently be answered. Where there are discrepancies between the documentation and the CHANGELOG, both are documented without favoring one over the other.

This article is based on documentation read on 2026-12-04, and Claude Code v2.1.336 (GitHub Release of 2026-12-03T20:16:11Z). Claude Code releases new versions several times a week. This article does not cover initial setup, receiver design, or pricing.

Related articles on this site:

Table of Contents

  1. 1. Scope and Assumptions
  2. 2. What to Enable
  3. 3. Metrics
  4. 4. Events
  5. 5. Attributes
  6. 6. Items Redacted by Default and Opt-In
  7. 7. What Administrators Can and Cannot Pin
  8. 8. Audit Questions and Events
  9. 9. Differences by Surface and Traces
  10. 10. Discrepancies Between the Documentation and the CHANGELOG
  11. 11. Frequently Asked Questions About OpenTelemetry for Claude Code
  12. 12. Summary
  13. 13. References

1. Scope and Assumptions

This chapter will first define the intended audience, the scope of this article, the materials referenced, the statement labels, and the usage of terminology. The following nine points will outline the conclusions.

  • Metrics cover 8 types, events cover 28 types, and traces have 6 span types. In addition to events, there is claude_code.system_prompt, which is only sent when both detailed beta tracing is enabled and OTEL_LOG_USER_PROMPTS=1 is set (chapters 3, 4, and 9).
  • claude_code.safety_event is no longer sent from v2.1.312. Only sessions from v2.1.307 to v2.1.311 may send this data. Rejected calls can be seen under tool_decision, but it may not always be clear which rule caused the rejection (section 4.2 and chapter 8).
  • The default for OTEL_EXPORTER_OTLP_PROTOCOL is http/protobuf from v2.1.323. For a gRPC collector on port 4317, specify grpc (chapter 2).
  • By default, the content of prompts, responses, tool arguments, tool outputs, and API bodies are redacted. However, if signed in with OAuth, user.email is included by default. Setting OTEL_LOG_USER_PROMPTS=1 alone will also include the content of responses (chapters 5 and 6).
  • When using managed settings to configure destinations or credentials, any destination variables set by the developer are cleared at startup. If managed settings do not explicitly specify an exporter, developers can set it to none (chapter 7).
  • From v2.1.282, a repository's .claude/settings.json and .claude/settings.local.json cannot enable telemetry, select destinations, or turn on content capture. Only off values take effect (section 7.5).
  • For local sessions in the Code tab of the Desktop application, the service.name is claude-code-desktop. According to the CHANGELOG, this applies from v2.1.332, and these sessions are excluded from dashboards filtered by claude-code (section 5.5).
  • The Agent SDK does not have its own telemetry; its child CLI process sends the same telemetry as the CLI. In sessions using API keys, Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry, attributes representing the user are limited to user.id and session.id (chapter 9).
  • There are 8 differences between the documentation and the CHANGELOG. A direct discrepancy is that the documentation states that Claude Code does not set gen_ai.usage.*, while the CHANGELOG for version 2.1.331 states that it was added to the claude_code.llm_request span (chapter 10).

1.1 Intended Audience

This article is intended for administrators, security personnel, and platform teams within organizations. It is aimed at readers who need to understand how data is named, what data is sent, what is redacted by default, and what questions cannot be answered when sending data to OTel collectors or SIEM systems. This article assumes readers have already completed introductory material on which variables to include when sending data and are now ready to configure dashboards, alerts, and audit questions. A basic understanding of OTel metrics, logs, traces, and resource attributes is a prerequisite.

1.2 Scope and Exclusions

This article covers the list of telemetry signals sent by Claude Code itself, their defaults, opt-in procedures, what administrators can pin, and their relationship to audit questions.

The following topics are covered in this site's existing articles:


The OTel implementation for Claude API (including spans for Messages API and Managed Agents) is a separate system from the OTel implementation for Claude Code. The monitoring page will direct you to a separate page for information on Claude API and Managed Agents (Stated).

Operational telemetry sent to Anthropic (which can be disabled with DISABLE_TELEMETRY) also follows a different path than the OTel discussed in this article. The monitoring page states that OTel transmission requires an opt-in configuration and explicit settings (Stated).

This article does not cover comparisons and configurations of collector and SIEM products, pricing and costs, or procedures for changing telemetry destinations.

1.3 Checked Date and Reviewed Materials

Verification date: 2026-12-04. The following materials were reviewed: 22 pages from the Claude Code documentation (including the monitoring page, the observability page for the Agent SDK, the server-managed settings page, the settings page and settings reference, the environment variables page, the costs page, the analytics page, the data usage page, the managed settings page, the Desktop page, the measure page for plugins, the administrator settings page, the Claude apps gateway settings page, and 8 pages related to mods), the Claude Code CHANGELOG, and the publication dates from GitHub Releases.

The monitoring page is approximately 186 KB in size and is updated frequently. This article does not copy long passages from the page. Tables give identifiers verbatim, while explanations are phrased in this article's own words. Direct quotes are used sparingly, limited to short sentences.

Version dates are recorded in UTC, taken from the published_at field in GitHub Releases. The CHANGELOG only lists version numbers and does not include dates.

1.4 Statement Labels

This article will apply the following four labels to each description:

LabelMeaning
StatedFound in a page within Claude Code's documentation. The specific page is noted in the text.
CHANGELOG onlyFound in a CHANGELOG entry, but not found on any page within the documentation that this article reviewed.
Not statedNot found on any reviewed pages within the documentation, nor in the CHANGELOG. This does not necessarily indicate that it does not exist.
InferenceReasoned by this article from statements in the documentation or the CHANGELOG.

The CHANGELOG only label does not mean that the information is not being sent; rather, it means that it is currently not documented in the documentation. Conversely, information present in the documentation is not necessarily being transmitted. claude_code.safety_event is an example of this.

This article has not verified anything by actually receiving telemetry. The names, defaults, and behavior described are all based on the documentation, the CHANGELOG, and inferences drawn from those sources.

1.5 Usage of Terms

  • Signal: Refers to the three components in OTel: metrics, logs (events), and traces. Used in the same sense as "signal" in the documentation.
  • Event: A record sent as a log within OTel, specifically pertaining to claude_code.* entries. This article uses "event" to refer only to these records sent by Claude Code. However, it does not include span events recorded within a span (such as tool.output) or hook events, which name a hook type such as PreToolUse.
  • Span: A segment within a trace, often identified by names such as claude_code.interaction.
  • Redact: To omit an attribute or replace its value with a placeholder such as <REDACTED> or custom.
  • Opt-in: To use a variable to send content that is redacted by default.
  • Managed settings: Configurations provided by administrators. This includes files placed on devices, MDM, and server-managed settings. These settings have the highest priority within Claude Code's configuration, except that the OTLP endpoint in the Enterprise Admin Console takes precedence over them (section 7.3).
  • Default: The value used when no specific configuration is provided. This article does not use it to mean unchangeable.

2. What to Enable

This chapter briefly verifies the necessary variables and default settings for the protocol. The introductory steps for the process are detailed in section 9.2 of Claude Code in CI/CD and Headless Automation.

2.1 Three Signals and How to Enable Each

Telemetry is sent by setting CLAUDE_CODE_ENABLE_TELEMETRY=1 and selecting an exporter for each signal (Stated, monitoring page).

SignalVariable to SelectValuesDefault Send Interval
MetricsOTEL_METRICS_EXPORTERotlp, prometheus, console, none60000 milliseconds (OTEL_METRIC_EXPORT_INTERVAL)
Events (Logs)OTEL_LOGS_EXPORTERotlp, console, none5000 milliseconds (OTEL_LOGS_EXPORT_INTERVAL)
Traces (beta)OTEL_TRACES_EXPORTERotlp, console, none5000 milliseconds (OTEL_TRACES_EXPORT_INTERVAL)

Multiple exporter values can be specified, separated by commas. For traces, you also need to set CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 (Stated). Trace conditions are described in section 9.3.

Destinations are specified using OTEL_EXPORTER_OTLP_ENDPOINT and, for each signal, using variables like OTEL_EXPORTER_OTLP_METRICS_ENDPOINT. Signal-specific endpoints and protocols take precedence over global variables. Signal-specific headers are merged with the global OTEL_EXPORTER_OTLP_HEADERS variable (Stated).

When using the prometheus exporter, values are ingested from http://localhost:9464/metrics (Stated). If only prometheus is selected, the system sends data without the USD, tokens, and s units to maintain the Prometheus text format. The names of the metrics remain unchanged (Stated).

2.2 The Protocol Default Is http/protobuf Starting from v2.1.323

The monitoring page states the following regarding OTEL_EXPORTER_OTLP_PROTOCOL (Stated).

Defaults to `http/protobuf` for a valid `http://` or `https://` endpoint. For a gRPC endpoint such as `http://localhost:4317`, set this to `grpc`.

This default takes effect from v2.1.323 onwards (Stated). The CHANGELOG for version 2.1.323 (2026-11-12) notes that previously, transmissions from the otlp exporter, when an endpoint was specified but the protocol was missing, would silently fail (CHANGELOG only).

Therefore, if you omit OTEL_EXPORTER_OTLP_PROTOCOL=grpc from the configuration for sending data to a gRPC collector on port 4317, the system will attempt to send data using http/protobuf from v2.1.323 onwards (Inference). To send data to a gRPC collector, you must explicitly specify grpc.

The variables for the client certificate used with mTLS differ depending on the protocol. For http/protobuf and http/json, use CLAUDE_CODE_CLIENT_CERT and CLAUDE_CODE_CLIENT_KEY. For grpc, use OTEL_EXPORTER_OTLP_CLIENT_KEY and OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE (Stated). The otelHeadersHelper, which creates dynamic headers, only works with http/protobuf and http/json (Stated).

2.3 What to Check When Nothing Arrives

The monitoring page says that if nothing arrives, you should start Claude Code with claude --debug-file <path> and review the log. Failures of the configured exporter will be indicated in the [3P telemetry] line. The [Anthropic telemetry] line relates to a separate telemetry stream sent to Anthropic and does not indicate configuration issues (Stated).

In the Agent SDK, transmission failures are, by default, silently discarded. Setting CLAUDE_CODE_OTEL_DIAG_STDERR=1 will cause exporter failures to be displayed in stderr (Stated, Agent SDK observability page and environment variables page).

CHANGELOG version 2.1.328 states that /status and claude doctor now provide notifications when an exporter is configured without an endpoint (CHANGELOG only).

3. Metrics

This chapter lists eight metrics, including their names, units, when they increase, and their specific attributes, in a table format.

3.1 List of Metrics

MetricUnitIncreases WhenAdditional Attributes (Beyond Standard)
claude_code.session.countNoneA session is startedstart_type (fresh, resume, continue, agents_view)
claude_code.lines_of_code.countNoneCode is added or removedtype (added, removed), model
claude_code.pull_request.countNoneA pull request or merge request is created (using a shell command or MCP tool)None
claude_code.commit.countNoneA git commit is createdNone
claude_code.cost.usageUSDWith each API requestmodel, query_source, speed, effort, agent.name, skill.name, plugin.name, marketplace.name, mcp_server.name, mcp_tool.name
claude_code.token.usagetokensWith each API requesttype (input, output, cacheRead, cacheCreation) and the same attributes as claude_code.cost.usage
claude_code.code_edit_tool.decisionNoneWhen a decision is made regarding permission for Edit, Write, or NotebookEdittool_name, decision (accept, reject), source, language
claude_code.active_time.totalsDuring active operation and processing (excluding idle time)type (user, cli)

The names, units, and attributes in the table are taken from the monitoring page (Stated). The meter name is com.anthropic.claude_code (Stated).

3.2 Important Notes for Reading

  • The input type in claude_code.token.usage does not include tokens read from the prompt cache or tokens written. Those are counted under cacheRead and cacheCreation. cacheCreation includes both the 5-minute and 1-hour cache entries (lifetime) (Stated).
  • The values for query_source can be main, subagent, auxiliary, plugin_model_complete, or plugin_model_classify. The last two are counted from v2.1.324 and are associated with requests to $.model.complete and $.model.classify made by mods. The total may increase after updates (Stated).
  • agent.name, skill.name, plugin.name, mcp_server.name, and mcp_tool.name default to replacing some names with custom or third-party. Setting OTEL_LOG_TOOL_DETAILS=1 will display the original names (Stated, chapter 6).
  • claude_code.session.count represents the number of sessions, not the number of users. This value increases if a single user initiates multiple sessions. To count users, refer to the monitoring page, which describes how to count unique values of user.account_uuid in the claude_code.user_prompt events (Stated).
  • The source attribute in claude_code.code_edit_tool.decision can be one of the following: config, hook, user_permanent, user_temporary, user_abort, or user_reject. The meaning of these values is the same as that of the tool_decision event (Stated).

3.3 The Cost Is an Estimate

The value of claude_code.cost.usage is approximate. The monitoring page is written to direct users to the "Costs" page for official billing data (Stated). According to the "Costs" page, Claude Code locally calculates the dollar value based on the number of tokens used, applying a standard price. If the administrator sets modelPricing in the managed settings, it will calculate the cost using that rate. This setting changes the value reported by Claude Code, but does not affect the amount Anthropic charges (Stated, v2.1.242 and later).

This article does not specify prices or unit costs. Details on how costs are displayed for each billing path can be found in section 8.2 of Claude Code on Pay-As-You-Go API Billing.

4. Events

This chapter lists 28 events and claude_code.system_prompt, which has no section of its own, all in a single table. These events are sent as OTel logs when OTEL_LOGS_EXPORTER is configured (Stated).

4.1 Event List

The fourth column in the table indicates attributes that are not sent when an opt-in variable is not set, or values that are replaced. The fifth column gives the Claude Code version that the event or its key attributes require. Blank spaces indicate that the version requirements are not specified on the page.

EventOccurs WhenKey AttributesRedacted by Default (opt-in)Version
claude_code.user_promptPrompt is sent. Includes turns initiated by Claude Code itself.prompt_length, message.uuid, command_name, command_sourceprompt and prompt_text (OTEL_LOG_USER_PROMPTS), command names for custom, plugin, and MCP commands (OTEL_LOG_TOOL_DETAILS)prompt_text is v2.1.287
claude_code.assistant_responseAfter an API request returns text. After a message is sent to the user by a tool.response_length, model, request_id, tool_use_id, message.uuid, query_sourceresponse (OTEL_LOG_ASSISTANT_RESPONSES. Follows OTEL_LOG_USER_PROMPTS if not set)Messages sent by tools are v2.1.332
claude_code.tool_resultWhen a tool execution completes. Not sent for rejected calls.tool_name, tool_use_id, request_id, success, duration_ms, error_type, decision_source, tool_input_size_bytes, tool_result_size_bytes, mcp_server_scopeerror, tool_parameters, tool_input, vcs.ref.head.* (OTEL_LOG_TOOL_DETAILS)request_id is v2.1.310
claude_code.api_requestEvery time an API request is made.model, cost_usd, cost_usd_micros, duration_ms, token counts, request_id, client_request_id, speed, query_source, effortAttribution name (OTEL_LOG_TOOL_DETAILS)Breakdown of 5-minute and 1-hour caching is v2.1.300
claude_code.api_errorWhen an API request fails. Once after abandoning retries.error, status_code, duration_ms, attempt, request_id, client_request_idAttribution name (OTEL_LOG_TOOL_DETAILS)
claude_code.api_refusalWhen the response stop_reason is refusal.model, request_id, attempt, server_fallback_hop, has_category, has_explanationcategory (OTEL_LOG_TOOL_DETAILS)
claude_code.api_request_bodyEvery time an API request is attempted.body or body_ref, body_length, body_truncated, request_body_idThe event itself (OTEL_LOG_RAW_API_BODIES)request_body_id is v2.1.274
claude_code.api_response_bodyEvery time a successful API response is received.body or body_ref, request_id, request_body_id, message.id, message.uuidThe event itself (OTEL_LOG_RAW_API_BODIES)request_body_id, message.id, message.uuid are v2.1.274
claude_code.tool_decisionWhen a permission decision is made for a tool.tool_name, tool_use_id, decision, source, tool_source, classifier_verdict, permission_mode, request_idtool_parameters, classifier_category (OTEL_LOG_TOOL_DETAILS)classifier_verdict, permission_mode, classifier_category are v2.1.301. request_id is v2.1.310
claude_code.safety_eventNot sent from v2.1.312category, decision, reason_code, rule_source, sandbox_violation_count and othersclassifier_category (OTEL_LOG_TOOL_DETAILS)Only v2.1.307 to v2.1.311
claude_code.permission_mode_changedWhen the permission mode changes.from_mode, to_mode, triggerNone
claude_code.authUpon completion of /login or /logout.action, success, auth_method, error_category, status_codeError body is never included
claude_code.mcp_server_connectionFor MCP server connection, disconnection, or connection failure.status, transport_type, server_scope, duration_ms, error_code, is_plugin, plugin_id_hash, plugin.nameserver_name, error, Names of third-party plugins (OTEL_LOG_TOOL_DETAILS)
claude_code.internal_errorFor unexpected internal errors within Claude Code.error_name, error_codeError body and stack trace are never included
claude_code.plugin_installedUpon completion of plugin installation.marketplace.is_official, install.triggerplugin.name, plugin.version, marketplace.name for third-party marketplaces (OTEL_LOG_TOOL_DETAILS)
claude_code.plugin_loadedOnce per enabled plugin at session start.plugin.scope, enabled_via, plugin_id_hash, has_hooks, has_mcp, safe_modeplugin.name and marketplace.name of non-official plugins (OTEL_LOG_TOOL_DETAILS)safe_mode is v2.1.169
claude_code.skill_activatedWhen a skill is activated.invocation_trigger, skill.source, skill.kindskill.name of user and third-party skills, plugin.name and marketplace.name of non-official plugins (OTEL_LOG_TOOL_DETAILS)
claude_code.at_mentionWhen a @ mention is resolved in a prompt.mention_type, successNonepeer value is v2.1.232
claude_code.api_retries_exhaustedFinal failure of an API request after multiple (2+) attempts. Sent once with the final api_error.model, error, status_code, total_attempts, total_retry_duration_ms, speedNone
claude_code.hook_registeredOnce per configured hook at session start.hook_event, hook_type, hook_source, safe_modehook_matcher, plugin.name of non-official plugins (OTEL_LOG_TOOL_DETAILS)safe_mode is v2.1.169
claude_code.hook_execution_startWhen a hook begins executing in response to an event.hook_event, hook_name, num_hooks, managed_only, hook_source, safe_modehook_definitions (detailed beta tracing and OTEL_LOG_TOOL_DETAILS)safe_mode is v2.1.169
claude_code.hook_execution_completeWhen all hooks have finished executing in response to an event.num_success, num_blocking, num_non_blocking_error, num_cancelled, total_duration_mshook_definitions (detailed beta tracing and OTEL_LOG_TOOL_DETAILS)Character-count attributes and num_outputs_persisted are v2.1.280
claude_code.hook_plugin_metricsWhen a hook on an official marketplace plugin emits a value.plugin_id, hook_event, Plugin value (up to 20)None
claude_code.compactionUpon completion of conversation compaction.trigger, success, duration_ms, pre_tokens, post_tokens, precompute_reuseNone
claude_code.subagent_completedSub-agent completionagent.source, is_built_in, is_async, total_tokens, total_tool_uses, duration_ms, model, final_modelagent_type for sub-agents that are not built-in or official plugins, plugin.name for plugins outside of the official ecosystem (OTEL_LOG_TOOL_DETAILS)
claude_code.feedback_surveyDisplay of and response to a session quality surveyevent_type, appearance_id, survey_type, response, enabled_via_overrideNone
claude_code.retention_sweepEach time files exceeding their retention period are cleanedresult, period_days, used_default, skip_reason, number of deletions, error_countNonev2.1.227
claude_code.managed_settings_resolvedSession start, changes in managed settings or policy helper status, startup rejection or session endmanaged_settings.trigger, error.type, managed_settings.sources, managed_settings.helper.statemanaged_settings.settings, managed_settings.resolved_sha256 (OTEL_LOG_MANAGED_SETTINGS)v2.1.274
claude_code.system_prompt (No section)First time a different system prompt is sent, and after compactionFull system promptThe event itself (both detailed beta tracing and OTEL_LOG_USER_PROMPTS)

The names, send timings, attributes, opt-ins, and versions in the table come from the individual sections of the monitoring page (Stated). The claude_code.system_prompt has no event section of its own; instead, it is described in one paragraph at the end of the section describing the content of the detailed beta tracing, and one item in the security and privacy section (Stated).

All events include standard attributes (section 5.1), as well as event.name, event.timestamp, and event.sequence (Stated).

4.2 safety_event Is No Longer Sent from v2.1.312

The monitoring page still includes the claude_code.safety_event section, but the section's introduction states that transmission has been discontinued (Stated).

* **v2.1.312 and later**: these versions don't send the event, and no setting turns it on

Sessions from v2.1.307 to v2.1.311 will stop sending this event once the feature flag is updated. Sessions that do not retrieve the feature flag, such as those for Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry, may continue to send the event (Stated). The remaining attributes described in the section pertain to events from v2.1.307 to v2.1.311 (Stated).

The documentation states that v2.1.307 to v2.1.311 send this event (Stated). The CHANGELOG for 2.1.307 (2026-10-21) indicates that this event was added, while the CHANGELOG for 2.1.312 (2026-10-27) states that transmission was stopped (CHANGELOG only). Currently, both the documentation and the CHANGELOG agree that this event is no longer being sent.

The monitoring page instructs users to use tool_decision to view instances where tool calls were rejected. However, while tool_decision indicates that a call was rejected, it does not always specify which check resulted in the rejection (Stated). The questions that safety_event used to answer but that the current version cannot answer are summarized in section 8.3.

If your dashboards or alert rules rely on claude_code.safety_event, no data will be received from sessions on v2.1.312 and later (Inference). A zero count of events should not be interpreted as a zero count of rejections.

4.3 Events Sent Only Under Conditions

Some events are sent only when certain conditions are met.

  • claude_code.api_error is sent only once, after Claude Code has internally given up on retries. Intermediate retries do not trigger separate events (Stated). When a temporary error exhausts the available retry attempts, the attempt value will be at most one greater than the effective retry limit, with a default value of 11. The default for CLAUDE_CODE_MAX_RETRIES is 10, and the configurable maximum is 15. Setting CLAUDE_CODE_RETRY_WATCHDOG will raise the default and remove the maximum limit. After a streaming failure, and if the request is resent, the attempt counter resets to 1 (Stated).
  • claude_code.api_retries_exhausted is sent when a request fails after multiple attempts (two or more), and is sent along with the final api_error (Stated).
  • claude_code.internal_error is not sent during sessions using Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry, nor is it sent in sessions where DISABLE_ERROR_REPORTING is enabled (Stated).
  • For claude_code.assistant_response, messages sent using tools (those with a tool_use_id) are only delivered when configured to include the body of the response (Stated).
  • claude_code.retention_sweep is sent at most once per session, regardless of whether any data is deleted. If a sweep has run on the same machine within 24 hours, the sweep is delayed by 10 minutes or more, so sessions that end early send nothing. It is also not sent when running claude -p with the --bare flag (Stated).
  • Events related to the rejection of startup for claude_code.managed_settings_resolved are not sent during interactive sessions in untrusted folders (Stated).
  • claude_code.at_mention sends a maximum of 100 entries for each of the agent and mcp_resource types during a single prompt read (Stated).

4.4 Events Listed Only in the CHANGELOG

The CHANGELOG for version 2.1.333 (2026-11-30) states that mods can now send their own records to the collector as a claude_code.plugin_event (CHANGELOG only). This event name cannot be found on the monitoring page or in the 8 pages dedicated to mods. This event will not be counted as one of the 28 types; it will be included in the table in chapter 10.

5. Attributes

This chapter lists the standard attributes that apply to all metrics and events, attributes specific to events, attributes that define correlations between events, resource attributes, and variables used to manage cardinality.

5.1 Standard Attributes and Whether Each Is On by Default

All metrics and events have the following standard attributes (Stated, monitoring page). The third column in the table indicates whether the attribute is sent when the variable is not set.

AttributeDescriptionDefault BehaviorControlled by Variable
session.idThe ID of the Claude Code session. Resets with /clear.SendsOTEL_METRICS_INCLUDE_SESSION_ID
ccr.session.idThe ID of the cloud session (defined by CLAUDE_CODE_REMOTE_SESSION_ID).Sends (only for cloud sessions)OTEL_METRICS_INCLUDE_SESSION_ID
app.versionThe version of Claude Code.Does not sendOTEL_METRICS_INCLUDE_VERSION
app.entrypointThe startup path. Possible values include: cli, sdk-cli, sdk-ts, sdk-py, claude-vscode, claude-desktop, claude-desktop-3p, claude-in-slack, remote, and others.Does not sendOTEL_METRICS_INCLUDE_ENTRYPOINT
organization.idThe organization's UUID (when authenticated).Sends whenever availableNone
user.account_uuid, user.account_idThe account's UUID, and the account ID in the tagged format used by Anthropic's admin APIs (when authenticated).SendsOTEL_METRICS_INCLUDE_ACCOUNT_UUID
user.idA random ID created during initial startup and saved to ~/.claude.json.Always sendsNone
user.emailThe email address used for sign-in. For cloud sessions, it reflects the credentials associated with that session.Sends whenever availableNone
terminal.typeThe type of terminal. Possible values include: iTerm.app, vscode, cursor, tmux, and others.Sends whenever detectedNone
OTEL_RESOURCE_ATTRIBUTES keysAttributes added by the organization, such as departments or teams.SendsOTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTES
vcs.repository.url.full, vcs.owner.name, vcs.repository.name, vcs.provider.nameIdentity derived from the origin of the session's repository.Does not send (v2.1.269 and later)OTEL_METRICS_INCLUDE_REPOSITORY

The user.id does not contain any personal information and is not created from a Claude account, according to the monitoring page (Stated). On the other hand, user.email is always sent whenever it is available. The security and privacy section of the monitoring page states (Stated):

When authenticated via OAuth, `user.email` is included in telemetry attributes, sent only to the OTel endpoint you configure, never to Anthropic.

Values for vcs.* are converted to lowercase, and do not include credentials from remote URLs, query strings, or fragments. The operational telemetry sent to Anthropic excludes vcs.* (Stated).

5.2 Claude Apps Gateway Session Identity

For sessions established through /login in the Claude apps gateway, the CLI attaches the authenticated user's identity. user.id will correspond to the IdP's subject, user.email will be the email address used for login, and user.groups will contain the groups provided by the IdP. The identity.source will be gateway-oidc. Note that any user.* and identity.* keys configured via OTEL_RESOURCE_ATTRIBUTES will be ignored (Stated).

However, events recorded before login will not have this identity. Boot-up events such as managed_settings_resolved, plugin_loaded, and mcp_server_connection may use an anonymous user.id and may not have an identity.source (Stated). The gateway's relay functionality is handled as described in section 3.4 of Running Claude Apps Gateway on AWS.

5.3 Attributes Specific to Events

The following attributes are exclusive to events and are not associated with metrics. This is because their values are unbounded and would increase the cardinality of metrics (Stated).

  • prompt.id: A UUID that links a single user prompt and all events that occur between that prompt and the subsequent prompt.
  • workspace.host_paths: An array of strings representing the working directories of the host selected in the Desktop environment.
  • workflow.run_id and workflow.name: These attributes are attached to the agent API and tool events that belong to a Workflow tool run. If OTEL_LOG_TOOL_DETAILS=1 is not set, the names of user-authored workflows become custom.
  • agent_id and parent_agent_id: The IDs of the sub-agent that triggered the event and the agent that initiated it. Available from v2.1.310 and later.

5.4 Attributes Connecting Events

The monitoring page lists the following attributes that connect events (Stated).

AttributeAssociated EventsUsage
prompt.idAll eventsCollects user_prompt, api_request, and tool_result events originating from a single prompt.
event.sequenceAll eventsStarts at 0 and is counted sequentially for each Claude Code process, not within each session.
message.uuiduser_prompt, assistant_response, api_response_bodyLinks to entries in the session transcript.
request_idapi_request, api_error, api_refusal, assistant_response, api_response_body, tool_result, tool_decisionThe value of the request-id header in the API response. In Amazon Bedrock, this is the value of x-amzn-requestid (v2.1.282 and later).
client_request_idapi_request, api_errorThe x-client-request-id created by Claude Code. Remains even in failures without a request_id, such as timeouts. Not present on requests to third-party providers or on requests retried through the non-streaming fallback.
tool_use_idtool_result, tool_decision, assistant_response sent by the tool, safety_event (excluding those at the end of a turn; v2.1.307 to v2.1.311 only)The same value as the tool_use_id passed to the hook.

Because event.sequence is counted for each process, it continues after a /clear command, and when resuming a session, it uses the value of the process that resumed the session. In the same session, it is possible for subsequent events to have smaller values or repeat the same value. The monitoring page says to sort events by event.timestamp and to use event.sequence to determine the order of events with the same timestamp (Stated).

Regarding how to connect to the transcript, the monitoring page notes that the format of the transcript is internal to Claude Code and changes with each version. Therefore, this linking method should be treated as version-dependent (Stated).

5.5 Resource Attributes and service.name

All metrics and events have the following resource attributes (Stated, the Service information section of the monitoring page).

  • service.name
  • service.version: The version of Claude Code. In local sessions in the Code tab, this refers to the version of the Desktop application.
  • os.type, os.version, host.arch
  • host.name, host.id: Not sent by default (see section 5.6).
  • wsl.version: Only when using WSL.

Regarding service.name, the monitoring page states the following (Stated):

* `service.name`: `claude-code` for terminal sessions, `claude-code-desktop` for local sessions started from the Code tab in the [Claude Desktop app](https://code.claude.com/docs/en/desktop.md)

The CHANGELOG, version 2.1.332 (2026-11-25), changed this default to claude-code-desktop (CHANGELOG only – the documentation does not specify version conditions for this value). If collectors or dashboards are filtering by service.name = claude-code, you will need to add claude-code-desktop (Stated, monitoring page). The CHANGELOG mentions OTEL_SERVICE_NAME as a means of maintaining the older name. This variable is not present on the monitoring page or the environment variables page, but an example can be found on the Agent SDK observability page (chapter 10).

5.6 Variables to Control Cardinality and Machine Identity

The following six variables determine the attributes applied to metrics and events (Stated).

VariableAttribute(s) to ApplyDefault
OTEL_METRICS_INCLUDE_SESSION_IDsession.id, ccr.session.idtrue
OTEL_METRICS_INCLUDE_VERSIONapp.versionfalse
OTEL_METRICS_INCLUDE_ACCOUNT_UUIDuser.account_uuid, user.account_idtrue
OTEL_METRICS_INCLUDE_ENTRYPOINTapp.entrypointfalse
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTESWhether to apply keys from OTEL_RESOURCE_ATTRIBUTES to data points and eventstrue
OTEL_METRICS_INCLUDE_REPOSITORYvcs.* (v2.1.269 and later)false

Keys defined in OTEL_RESOURCE_ATTRIBUTES are applied not only in the resource block but also, by default, to all data points and events. In cases of conflicting keys, the standard attribute value is retained, except for vcs.* (Stated). There are formatting restrictions, such as values not being allowed to contain spaces (Stated).

The machine's name and ID are only included in the resource block as host.name and host.id when OTEL_RESOURCE_INCLUDE_HOST=1 is configured (v2.1.326 and later). The host.id is the OS machine ID and is not hashed (Stated). The monitoring page says that because hostnames often contain personal names and host.id identifies the machine over the long term, you should inform users if you set OTEL_RESOURCE_INCLUDE_HOST in managed settings. Claude Code does not provide notifications to users (Stated).

6. Items Redacted by Default and Opt-In

This chapter lists the items that are redacted by default, and six variables that users can opt-in to enable. The monitoring page states that, by default, the contents of files and code snippets are not included in metrics and events (Stated).

6.1 Figure 1: What Claude Code Telemetry Includes at Each Opt-In Level

What Claude Code Telemetry Includes at Each Opt-In Level
What Claude Code Telemetry Includes at Each Opt-In Level
Figure 1 illustrates how the content transmitted increases incrementally as opt-in variables are added, building from the default state. The order of the tiers corresponds to the expanding scope of the transmitted content, and there is no predetermined order between the variables themselves (Inference). That OTEL_LOG_RAW_API_BODIES includes consent to the content of OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT is documented on the monitoring page (Stated).

6.2 Six Opt-In Variables

VariableAdded DataConditions and Notes
OTEL_LOG_USER_PROMPTSThe prompt and prompt_text from user_prompt, and the user_prompt within the span of claude_code.interaction. In detailed beta tracing, also includes new_context, system_reminders, system_prompt_preview, user_system_prompt, response.model_output, and the claude_code.system_prompt event.If OTEL_LOG_ASSISTANT_RESPONSES is not configured, the body of the response will also be included.
OTEL_LOG_ASSISTANT_RESPONSESThe response from assistant_response.Follows the settings of OTEL_LOG_USER_PROMPTS if not configured. Setting to 0 keeps responses out of events while prompts are still logged (see section 6.3 for response.model_output).
OTEL_LOG_TOOL_DETAILSThe tool_parameters from tool_result and tool_decision, and the tool_input and error from tool_result. Also includes the name of the command, the original names of metrics and API events, the name of the MCP server, classifier_category, the category from api_refusal, the server_name and error from mcp_server_connection, the hook_matcher from hook_registered, vcs.ref.head.* from tool_result, the file_path within the span of claude_code.tool, full_command, skill_name, subagent_type, workflow.name, the full text of the error within the span of claude_code.tool.execution, the file_path from the span event of tool.output, bash_command, and diff. In detailed beta tracing, also includes tool_input and hook_definitions.Includes Bash commands, file paths, URLs, and search queries.
OTEL_LOG_TOOL_CONTENTThe tool.output span event within the span of claude_code.tool (the body returned by Read, the output of Bash, and the results returned by MCP, WebFetch, and WebSearch). In detailed beta tracing, also includes new_context within the span of claude_code.tool (the tool's result).Tracing is required. Edit and Write also require OTEL_LOG_TOOL_DETAILS. MCP, WebFetch, and WebSearch are supported from v2.1.283 and later.
OTEL_LOG_MANAGED_SETTINGSThe managed_settings.settings (the shape of the configured settings with values redacted) and managed_settings.resolved_sha256 from managed_settings_resolved.Supported from v2.1.274 and later. Not effective for project and local settings.
OTEL_LOG_RAW_API_BODIESEvents for api_request_body and api_response_body. Setting to 1 includes the body as an attribute; setting to file:<dir> writes the body to a file and refers to it using body_ref.May include the entire conversation history. Includes consent to data revealed by OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT. Extended thinking content is always redacted.

The contents of this table are based on the common variable table on the monitoring page, as well as the sections for each event, and the security and privacy sections (Stated).

Regarding OTEL_LOG_RAW_API_BODIES, the monitoring page states the following (Stated):

Enabling this implies consent to everything `OTEL_LOG_USER_PROMPTS`, `OTEL_LOG_TOOL_DETAILS`, and `OTEL_LOG_TOOL_CONTENT` would reveal.

6.3 USER_PROMPTS Adds More Than Just Prompts

Setting only OTEL_LOG_USER_PROMPTS=1 will also send the body of the assistant_response because OTEL_LOG_ASSISTANT_RESPONSES is not configured (Stated). If you only want to collect prompts, you should also set OTEL_LOG_ASSISTANT_RESPONSES=0.

Furthermore, in detailed beta tracing, the response.model_output attribute of the claude_code.llm_request span contains the model's output. This attribute follows OTEL_LOG_USER_PROMPTS rather than OTEL_LOG_ASSISTANT_RESPONSES (Stated). Even if you set OTEL_LOG_ASSISTANT_RESPONSES=0, if detailed beta tracing is enabled, the model's output will still be received from the span (Stated, the Security and privacy section of the monitoring page).

To remove the prompt body in the collector, you need to explicitly exclude both prompt and prompt_text. The monitoring page provides an example of how to exclude both using the OpenTelemetry Collector's attributes processor (Stated).

6.4 What Is Included Without Opt-In

The statement that content is redacted by default does not mean that personal information or names are entirely excluded. Even if opt-in variables are not explicitly set, the following data will be transmitted (Stated):

  • If signed in via OAuth, user.email (see section 5.1).
  • organization.id, user.account_uuid, user.account_id (when authenticated).
  • The host working directories selected in Desktop (workspace.host_paths).
  • The MCP names of Claude Desktop's built-in servers. In sessions managed by Claude Desktop, mcp_server_name and mcp_tool_name will be included in the tool_parameters of tool_decision and tool_result. These are names chosen by the host application and are not part of the argument content (v2.1.214 and later).
  • The names of official marketplace plugins, as well as the names of built-in servers, servers accessed through claude.ai, and servers on the official registry.
  • managed_settings.helper.path within managed_settings_resolved (when a policy helper is selected).
  • The names of user-defined skills, which are included in the skill.name of the cost and token counters. The monitoring page treats the counters and the event differently: the counters carry user-defined skill names verbatim, while the skill_activated event replaces them with custom_skill unless OTEL_LOG_TOOL_DETAILS=1 is set.
  • hook_name for hook_execution_start and hook_execution_complete. It includes the matcher, as in PreToolUse:Write. The hook_matcher in the hook_registered event is sent only when OTEL_LOG_TOOL_DETAILS=1 is set.

Conversely, the names of plugins distributed from an organization's own marketplace are, by default, redacted. The measure page for plugins states that, by default, the names of plugins from outside the official marketplace, including those from an organization's marketplace, are either redacted or omitted (Stated).

6.5 Maximum Length

Attributes containing data are truncated to a length determined by the CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH variable. The default value is 61440, representing UTF-16 code units and including the truncation marker (approximately 60 KB). This default value is configured to fit backends that cap values at 64 KB (Stated). If the OTel SDK's attribute value length limit (such as OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT) is smaller, the value is truncated to that limit (Stated).

Other length limits are as follows (Stated):

  • tool_result's tool_input: Values are truncated if they exceed 512 characters, with a total limit of approximately 4K characters.
  • managed_settings.settings: Truncated at 8KB in UTF-8. The truncated value is not valid JSON.
  • tool_parameters's full_command: Not truncated.

7. What Administrators Can and Cannot Pin

This chapter outlines the extent to which administrators can pin telemetry settings, and the areas where developers retain the ability to make changes.

7.1 Figure 2: Who Can Change Claude Code Telemetry Settings

Who Can Change Claude Code Telemetry Settings
Who Can Change Claude Code Telemetry Settings
Figure 2 lists the locations that determine telemetry settings, along with what each location is authorized to configure. The content within each section is based on the descriptions in sections 7.2 through 7.6 (Stated). Arranging the five locations in a single vertical order is this article's own organization (Inference).

7.2 Managed Settings Pin Destination and Credentials as One Unit

When setting variables with OTEL_EXPORTER_OTLP_* in managed settings, Claude Code will, upon startup, remove the conflicting developer-configured variables and leave a warning in the debug logs (Stated, monitoring page).

  • Endpoint: The OTEL_EXPORTER_OTLP_ENDPOINT setting in managed settings removes all developer-configured per-signal endpoints.
  • Protocol: The OTEL_EXPORTER_OTLP_PROTOCOL setting in managed settings removes all developer-configured per-signal protocols.
  • Credentials: The OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_CLIENT_KEY, and OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE settings in managed settings remove the developer-configured per-signal variables of the same kind, as well as all developer-configured endpoints. This is to prevent credentials from being sent to a collector not selected by managed settings.
  • Detailed beta tracing BETA_TRACING_ENDPOINT: If managed settings determine the destination for logs or traces, they remove the value configured by the developer (prior to v2.1.251, developer-configured values could override the destination for both logs and traces).

This behavior is present from v2.1.217 and later. Prior to this version, variables were prioritized independently, which let a per-signal endpoint in user settings or the shell divert that signal away from the managed collector (Stated).

The monitoring page limits the scope of this removal (Stated).

This removal behavior changes where telemetry is delivered, not what Claude Code collects.

When there are multiple administrator settings sources (such as server-managed settings, MDM, or device files), certain rules apply. According to the server-managed settings page, the following environment variables (OTEL_EXPORTER_OTLP_*, OTEL_LOG_*, OTEL_LOGS_EXPORTER, ENABLE_BETA_TRACING_DETAILED, BETA_TRACING_ENDPOINT) are treated as a telemetry unit and are taken as one unit from the highest-priority source that sets any of these variables. An endpoint from one configuration source will not be combined with credentials from another. A source that sets the otelHeadersHelper credentials key also takes this unit. For OTEL_METRICS_EXPORTER and OTEL_TRACES_EXPORTER, settings are applied on a per-key basis (Stated, v2.1.223 and later).

7.3 The OTLP Endpoint in the Enterprise Admin Console Takes Precedence over Managed Settings

When you configure an OTLP endpoint in the Telemetry & updates section of the Enterprise Admin Console, terminal sessions that export there will not adhere to endpoint, protocol, or gRPC certificate variables. Even if you configure OTEL_EXPORTER_OTLP_ENDPOINT in managed settings, those sessions will be sent to the console's collector (Stated, monitoring page).

Since v2.1.331, /status shows a Telemetry row only for terminal sessions that received a collector from the console. If a row begins with not sent to, it indicates that the data is not being sent (Stated). For sessions sent to the console's collector, the mTLS variables in the monitoring page's http/protobuf and http/json row are used, and the variables in its grpc row are ignored (Stated).

7.4 Developers Can Change the Exporter Choice Unless Managed Settings Set It

Even if destination and credentials are pinned within managed settings, the exporter selection remains configurable. According to the monitoring page, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER, and the beta OTEL_TRACES_EXPORTER follow the standard key-based priority. Developers can still turn off a signal or switch to the console exporter. To pin these, you must also place them within managed settings (Stated, v2.1.223 and later).

Administrators who want to prevent data transmission from being stopped must place the values for all three exporters within managed settings, in addition to the destination and credentials (Inference).

7.5 In Project and Local Settings, Only Off Values Take Effect

Since v2.1.282, Claude Code ignores OTel variables in the env of the repository's .claude/settings.json and .claude/settings.local.json. The repository cannot be configured to enable telemetry, select destinations, or capture content (Stated, monitoring page and settings reference).

The settings reference lists the following variables that are ignored (Stated):

  • CLAUDE_CODE_ENABLE_TELEMETRY, CLAUDE_CODE_ENHANCED_TELEMETRY_BETA, ENABLE_ENHANCED_TELEMETRY_BETA
  • Variables related to the selection of three exporters.
  • OTEL_LOG_USER_PROMPTS, OTEL_LOG_ASSISTANT_RESPONSES, OTEL_LOG_TOOL_CONTENT, OTEL_LOG_TOOL_DETAILS
  • OTEL_EXPORTER_OTLP_* variables ending in _ENDPOINT, _HEADERS, _PROTOCOL, _CERTIFICATE, _CLIENT_KEY, and _INSECURE.
  • OTEL_EXPORTER_PROMETHEUS_HOST, OTEL_EXPORTER_PROMETHEUS_PORT, OTEL_RESOURCE_INCLUDE_HOST

Variables such as OTEL_LOG_RAW_API_BODIES, and ENABLE_BETA_TRACING_DETAILED and BETA_TRACING_ENDPOINT (related to detailed beta tracing) have been ignored since v2.1.251, as they relate to variables that export session content (Stated). Additionally, OTEL_LOG_MANAGED_SETTINGS does not take effect with project or local settings (Stated).

Only off values take effect in project and local settings. The settings reference lists examples such as none for the three exporters, and values of 0 for OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_CONTENT, and OTEL_LOG_TOOL_DETAILS to disable those features (Stated). While OTEL_LOG_ASSISTANT_RESPONSES is listed as an ignored variable, it does not appear in the list where off values take effect (Stated).

This off value takes precedence over the same variable configured in the user settings, but not over the same variable set by the environment Claude Code starts from, a --settings file, or managed settings (Stated). In other words, if an administrator puts the exporter value in managed settings, the repository's none does not take effect (Inference).

When these variables are configured in project or local settings, the local interactive session will display a notification at startup. The -p execution and Agent SDK sessions will not display notifications (Stated). If you are updating from a version prior to v2.1.282 in a CI environment, it is necessary to verify that the collector is still receiving data.

7.6 Approval Dialog for Server-Managed Settings

For some of the env variables distributed through server-managed settings, an approval dialog will be presented to the user. According to the server-managed settings page, the OTEL_EXPORTER_OTLP_ENDPOINT variable requires approval if it has a non-empty value (Stated). The variables ENABLE_BETA_TRACING_DETAILED and OTEL_LOG_RAW_API_BODIES will not present a dialog if they have a falsy value (such as 0), but will require approval for any other value (Stated). The OTEL_LOG_MANAGED_SETTINGS variable can be configured without a dialog, as it only adds the organization's own policy, with values redacted, to events the organization already receives (Stated, monitoring page).

The server-managed settings page also states that updates to OTel exporter settings will not take effect during the current session, but rather from the next startup (Stated).

7.7 Claude Code Does Not Pass OTEL Variables to Subprocesses

Claude Code does not pass OTEL_* environment variables to subprocesses it launches, including Bash tools, hooks, MCP servers, and language servers (Stated). Applications that are OTel-compatible and run within Bash tools will not inherit Claude Code's destination or headers.

Conversely, when tracing is enabled, Bash and PowerShell subprocesses inherit the W3C trace context of the currently running tool's span via the TRACEPARENT environment variable (Stated). This behavior follows the same settings as the traceparent header and, by default, only applies when connected directly to the Anthropic API. When using a custom ANTHROPIC_BASE_URL, the CLAUDE_CODE_PROPAGATE_TRACEPARENT=1 setting is required. The environment variables page also includes subprocesses launched by hooks (Stated). Claude Code passes only the trace linkage, not the destination (Inference).

8. Audit Questions and Events

This chapter lists, for each question raised during the audit, which attributes of which events should be examined. The monitoring page positions OTel events as the data source for auditing Claude Code's activities, stating that all events possess identity attributes (Stated).

8.1 Mapping Questions to Events

The following table is a restatement of the section "Map security questions to events" on the monitoring page, presented in the language of this article (Stated). The fourth column indicates whether that row is applicable in sessions v2.1.312 and later.

QuestionEventAttributesCurrent Version
Was the tool call permitted or rejected? Did the decision come from settings, a hook, or the user?tool_decisiondecision, source, classifier_verdict, permission_mode, tool_name. Requires OTEL_LOG_TOOL_DETAILS=1 for tool_parameters.Available
Which check rejected the call or requested a permission prompt?safety_eventcategory, decision, reason_code, rule_source, tool_name, tool_use_id.Not available (versions v2.1.307 to v2.1.311 only)
Did the classifier in auto mode permit or block the call? Or was it rejected without a verdict?tool_decision (when classifier_verdict is present)classifier_verdict, permission_mode, tool_name. Requires OTEL_LOG_TOOL_DETAILS=1 for classifier_category.Available
Was the permission mode elevated?permission_mode_changedfrom_mode, to_mode, trigger.Available
For each call, which permission mode was used? Includes calls from sub-agents.tool_decisionpermission_mode, session.id.Available
Did a policy hook block the action?hook_execution_completehook_event, num_blocking. Not associated with specific calls or tool_use_id.Available
Which tool calls did a hook reject?tool_decision (when decision is reject and source is hook)decision, source, tool_use_id.Available
Which result did a hook block, and at which turn's end?safety_event (when category is hook_review)category, hook_event, tool_use_id.Not available
Did the sandbox network proxy reject a connection for a Bash or PowerShell command?safety_event (when sandbox_violation_count is not 0)sandbox_violation_count, category, sandbox_enabled, tool_use_id.Not available
Login, logout, and authentication failures.authaction, success, error_category.Available
MCP server connection attempts and failures.mcp_server_connectionstatus, server_name, is_plugin, error_code.Available
Which plugin was installed, and from where?plugin_installedplugin.name, marketplace.name, marketplace.is_official.Available
The command executed and the files accessed.tool_result (when executed), tool_decision (when rejected). Requires OTEL_LOG_TOOL_DETAILS=1.tool_parameters, tool_input (for tool_result only).Available
Which managed settings source is the machine running on? Is the policy helper functioning correctly, and why was the startup rejected?managed_settings_resolvedmanaged_settings.trigger, managed_settings.sources, managed_settings.source_behavior, managed_settings.helper.state, error.type. Requires OTEL_LOG_MANAGED_SETTINGS=1 for settings format and hash.Available

The monitoring page indicates that the safety_event row in this table applies only to sessions that still send the event, from v2.1.307 to v2.1.311 (Stated).

To audit MCP activity, enable the log exporter and set the environment variable OTEL_LOG_TOOL_DETAILS=1. In tool_decision, the tool_name for the MCP server, as configured by the user, is always the string mcp_tool, regardless of this variable. Server and tool names are only included in the tool_parameters when this variable is set. Otherwise, neither the name nor the arguments are included (Stated).

8.2 Egress Paths, Managed Controls, and Events

The "Monitoring" page, specifically the section "Map egress paths to managed controls and events," maps the paths that can carry session content off the machine, and local retention, to the managed settings keys that restrict them and the events that record them (Stated).

PathManaged Settings KeyEvent
Bash and PowerShell commandssandbox.enabled, sandbox.failIfUnavailable, sandbox.allowUnsandboxedCommands, sandbox.network.allowManagedDomainsOnly, sandbox.network.allowedDomainstool_decision, tool_result
MCP ServerallowedMcpServers, allowManagedMcpServersOnly, deniedMcpServers, managed-mcp.jsonmcp_server_connection, tool_decision, tool_result
HookallowManagedHooksOnly, allowedHttpHookUrlshook_registered, hook_execution_start, hook_execution_complete
PluginstrictKnownMarketplaces, disableSideloadFlags, syncClaudeAiPlugins, syncClaudeAiSkillsplugin_installed, plugin_loaded
WebFetchpermissions.deny, allowManagedPermissionRulesOnlytool_decision, tool_result
Tools that upload to claude.ai (like Artifact)permissions.deny, enableArtifacttool_decision, tool_result
Remote ControldisableRemoteControlNo dedicated event
Local transcript retentioncleanupPeriodDaysretention_sweep

The monitoring page provides information regarding this table's allowedHttpHookUrls, managed-mcp.json, and hook events (Stated). allowedHttpHookUrls accumulates across configuration files, allowing developers to add entries to an empty managed list. The allowManagedHooksOnly setting determines which hooks are active. For managed-mcp.json, the page provides links to instructions on how to completely stop the MCP and how to verify whether Claude Code is reading the file. The hook_execution_start and hook_execution_complete events are recorded once for each hook event, covering all matching hooks. Setting OTEL_LOG_TOOL_DETAILS=1 alone does not record HTTP hook URLs. Hook configurations appear only in hook_definitions, which also requires detailed beta tracing.

The commands, names, and tool inputs provided when OTEL_LOG_TOOL_DETAILS=1 is enabled may contain content as sensitive as the session itself. The monitoring page says to enable it only for collectors authorized to hold that content (Stated).

8.3 Questions That Cannot Be Answered in the Current Version

Based on the tables in sections 8.1 and 8.2, this section collects questions that cannot be answered solely from Claude Code telemetry data within sessions from v2.1.312 onwards.

QuestionReasonLabel
Which permission rule or setting rejected the call?No tool_decision attribute names the rule or setting that caused the rejection. No safety_event is sent.Stated
Which result did a hook block, and at which turn's end?The tables only provide answers through safety_event. hook_execution_complete is not linked to either the call or the tool_use_id.Stated (table) and Inference (conclusion that it cannot be answered currently)
Did the sandbox network proxy reject the command's connection?The tables only provide answers through the sandbox_violation_count within safety_event (the number of rejections). No other event is listed in the table. The safety_event also does not include the names of the hosts that were rejected.Stated (table and attribute) and Inference (conclusion that it cannot be answered currently)
Usage of Remote ControlThe egress-path table says there is no dedicated event.Stated
URL destination for HTTP hooksThis is not recorded with just OTEL_LOG_TOOL_DETAILS=1. Detailed beta tracing and the hook_definitions are required.Stated
Who called Claude within the Claude Tag channel?Claude Tag sessions operate using a shared organization identity. The user.* attributes do not identify the caller.Stated
Who is operating the session within API Key, Amazon Bedrock, Google Cloud's Agent Platform, and Microsoft Foundry?There is no Claude account, so only user.id and session.id are available. Organizations can assign their own attributes through OTEL_RESOURCE_ATTRIBUTES.Stated

Regarding tool_decision, the monitoring page states (Stated):

No `tool_decision` attribute names the permission rule or setting that refused the call.

Even when source is config, the attributes alone do not show which of the following it came from. The candidates are project settings, user settings (allow or deny), managed policies, the specification of --allowedTools or --disallowedTools, the permission mode, the auto mode classifier, session permissions, and inherently safe tools. Even if the request for a permission prompt fails, the source will still be categorized as a config. If a classifier_verdict is available, the classifier's result can be determined (Stated).

8.4 Claude Code Sends Only Raw Events

The monitoring page concludes the auditing section with the following statement (Stated):

Claude Code emits the raw event stream only. Anomaly detection, baselining, correlation across sessions, and alerting are the responsibility of your SIEM or observability backend.

Anomaly detection, baseline comparisons, cross-session correlations, and alerts are all constructed on the receiving end. The tables in this article indicate which events and attributes can be used as input to such detection and alerting rules, but do not detail the rules themselves.

9. Differences by Surface and Traces

This chapter details how telemetry data varies across the surfaces that run Claude Code and outlines the span configurations for tracing.

9.1 Differences by Surface

SurfaceData SentConfiguration Location and Notes
Terminal CLIAll content from chapters 3 through 6. service.name is claude-code.Managed settings, user settings, and shell. Project and local settings apply only off values (see section 7.5).
Desktop Code Tab (Local Session)Same as CLI. service.name is claude-code-desktop (according to CHANGELOG, v2.1.332 and later), service.version is the version of the Desktop application. When OTEL_METRICS_INCLUDE_ENTRYPOINT=true, app.entrypoint is claude-desktop or claude-desktop-3p.Place in the env section of Claude Code's managed settings. Retrieves some variables from the shell profile, but does not retrieve OTEL_RESOURCE_INCLUDE_HOST.
Desktop SSH SessionData sent from Claude Code on the remote machine. SSH connections themselves do not generate metrics or events.Place variables in the managed settings file on the remote machine. Settings configured on the machine running the Desktop will not be passed to the SSH session.
CoworkData sent to the OpenTelemetry collector via the "Monitoring" form in the Data and privacy settings of the management console.This form only applies to Cowork sessions; it does not send data from the terminal CLI or Code tab. Cowork sessions do not receive server-managed settings.
Agent SDKData sent from the CLI of child processes. The SDK does not have its own telemetry.Process environment or options.env. In TypeScript, env replaces the inherited environment. Do not use the console exporter. TRACEPARENT is automatically propagated.
Cloud Sessions and Claude TagStandard attributes include ccr.session.id. When OTEL_METRICS_INCLUDE_ENTRYPOINT=true, the app.entrypoint for Claude Tag is claude-in-slack. host.name and host.id are not included.Place in the env section of server-managed settings or in the cloud environment variables. Claude Tag does not receive server-managed settings; it can only be configured through environment variables. Do not place credentials in environment variables. Add the collector's domain to the environment's allowed list.
Claude apps gatewayThe CLI sends data to the gateway, which then relays it as is to each destination. Includes user.id, user.email, and user.groups with the IdP identity.The forward_to setting in the gateway's telemetry defaults to relaying only metrics for each destination.
API Keys, Amazon Bedrock, Google Cloud's Agent Platform, Microsoft FoundryOnly user.id and session.id are used to represent the user. internal_error is not sent (except for API keys). For Amazon Bedrock, request_id is the value of x-amzn-requestid.The organization attaches the identity using OTEL_RESOURCE_ATTRIBUTES. client_request_id is not attached for third-party providers. The traceparent header is not sent to third-party providers.

The content is based on the monitoring page, the Desktop page, the Agent SDK observability page, and the Claude apps gateway settings page (Stated).

Regarding the Agent SDK, the observability page states (Stated):

The SDK does not produce telemetry of its own.

The Agent SDK page notes that because the console exporter writes to standard output, it may conflict with the flow of SDK messages (Stated).

Concerning SSH sessions on the Desktop, the Desktop page states that Desktop SSH connections do not contribute to Claude Code metrics and events (Stated). However, the monitoring page, following an example of naming a remote machine, states (Stated):

Desktop SSH sessions and the CLI on that machine both send it.

While the SSH connection itself is not recorded, telemetry from the SSH session is sent from the remote machine's Claude Code. To determine which machine it ran on, you can either set OTEL_RESOURCE_INCLUDE_HOST=1 on the remote machine or specify the machine's name in the OTEL_RESOURCE_ATTRIBUTES (Stated).

9.2 Trace Spans

When tracing is enabled, a tree of spans, rooted in claude_code.interaction, is created for each user prompt (Stated, monitoring page).

spanParentKey AttributesContent Attributes and Conditions
claude_code.interactionNone (When configured with the Agent SDK or -p and TRACEPARENT, the parent is the caller's span)user_prompt_length, interaction.sequence, parent.source, interaction.duration_msuser_prompt (when OTEL_LOG_USER_PROMPTS is enabled). In detailed beta tracing, new_context.
claude_code.llm_requestclaude_code.interaction. For sub-agents, it is the parent's claude_code.tool. The llm_request.context indicates the parent type.model, gen_ai.system, gen_ai.request.model, query_source_safe, agent_id, speed, effort, duration_ms, ttft_ms, token counts, request_id, gen_ai.response.id, attempt, success, error_class, stop_reason, gen_ai.response.finish_reasonsIn detailed beta tracing, new_context, system_reminders, system_prompt_preview, user_system_prompt, response.model_output (all when OTEL_LOG_USER_PROMPTS is enabled).
claude_code.toolclaude_code.interaction. For sub-agents, it is the parent's claude_code.tool.tool_name, tool_name_safe, bash_command_class, bash_argv0, duration_ms, result_tokens, tool_use_id, gen_ai.tool.call.idfile_path, full_command, skill_name, subagent_type, workflow.name (when OTEL_LOG_TOOL_DETAILS is enabled). Span event for tool.output (when OTEL_LOG_TOOL_CONTENT is enabled). In detailed beta tracing, new_context (when OTEL_LOG_TOOL_CONTENT is enabled) and tool_input (when OTEL_LOG_TOOL_DETAILS is enabled).
claude_code.tool.blocked_on_userclaude_code.toolduration_ms, decision (accept, reject, cancelled), sourceNone
claude_code.tool.executionclaude_code.toolduration_ms, tool_use_id, success, error, error_classFull text of error (when OTEL_LOG_TOOL_DETAILS is enabled)
claude_code.hookclaude_code.interactionhook_event, hook_name, num_hooks, duration_ms, num_success, num_blockinghook_definitions (when OTEL_LOG_TOOL_DETAILS is enabled). The span itself is only present during detailed beta tracing.

When a failure occurs, spans labeled llm_request, tool.execution, and hook will set the OTel status to ERROR. All other spans will consistently end with a status of UNSET (Stated). With each retry, a span event for gen_ai.request.attempt is recorded (Stated).

When directly connected to the Anthropic API, requests to the model carry a W3C traceparent header in the context of the claude_code.llm_request span. This header is not sent to third-party providers (Stated). When using a proxy via ANTHROPIC_BASE_URL, the traceparent header will only be sent if the CLAUDE_CODE_PROPAGATE_TRACEPARENT=1 environment variable is set (Stated).

9.3 Tracing Is in Beta and Has Two Tiers

The tracing system has two tiers (Stated, monitoring page and environment variables page).

  • Tracing: Set CLAUDE_CODE_ENABLE_TELEMETRY=1, CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1, and OTEL_TRACES_EXPORTER. Default is off.
  • Detailed beta tracing: Additionally, set ENABLE_BETA_TRACING_DETAILED=1 and BETA_TRACING_ENDPOINT. This adds the claude_code.hook span and attributes that carry content. Logs and traces are sent to BETA_TRACING_ENDPOINT instead of the configured exporter. For interactive CLI sessions, the organization must be on the allowlist. This is not required for Agent SDK or -p sessions.

The monitoring page warns that detailed beta tracing should only be used for debugging, not in production. The volume of data is high, and the content attributes are not part of the stable span schema (Stated).

The Agent SDK's observability page notes that span names and attributes may change (Stated). This same information is not found on the monitoring page.

Span names and attributes may change between releases.

10. Discrepancies Between the Documentation and the CHANGELOG

This chapter lists instances where the documentation (docs) and the CHANGELOG differ, or items that appear only in the CHANGELOG. This article does not determine which is correct. To verify, check the attributes delivered to your own collector.

ItemDocsCHANGELOG (Version and GitHub Release Date)
claude_code.llm_request's gen_ai.usage.*The monitoring page states that Claude Code does not set gen_ai.usage.*. It describes how to calculate the total number of tokens for input, including cache, by summing input_tokens, cache_read_tokens, and cache_creation_tokens.Version 2.1.331 (2026-11-23) states that gen_ai.usage.* is included, and that gen_ai.usage.input_tokens includes tokens from the prompt cache.
gen_ai.response.model, gen_ai.operation.nameNot listed in the span table.Version 2.1.331 (2026-11-23) states that these were added to claude_code.llm_request.
gen_ai.provider.name, gen_ai.conversation.id, gen_ai.tool.name, span's error.typeNot listed in the span table. The gen_ai.* attributes included in the table are gen_ai.system, gen_ai.request.model, gen_ai.response.id, gen_ai.response.finish_reasons, and gen_ai.tool.call.id.Version 2.1.300 (2026-10-14) states that GenAI semantic convention attributes were added to spans, citing these four as examples.
anthropic.plan, anthropic.seat_type, anthropic.provider, anthropic.custom_base_urlNo description available.Version 2.1.317 (2026-11-03) states that these were added to metrics, events, and spans.
claude_code.plugin_eventNo description available on either the monitoring page or the mods pages.Version 2.1.333 (2026-11-30) states that this allows the mod to send its logs to the collector under this name.
user_prompt's delivery.modeNo description available.Version 2.1.325 (2026-11-13) states that a missing user_prompt event for a message sent during tool execution was fixed. The event now includes delivery.mode: "mid_turn" and the prompt.id for the current turn.
OTEL_EXPORTER_OTLP_TIMEOUTNot listed on the monitoring page or the environment variables page.Version 2.1.317 (2026-11-03) states that this variable allows extending the timeout for sending data behind unresponsive proxies from 10 seconds to a maximum of 30 seconds. Version 2.1.323 (2026-11-12) states that the proxy wait time is set to 25 seconds, which is also the maximum allowed by this variable (previously 30 seconds).
OTEL_SERVICE_NAMENot listed on the monitoring page or the environment variables page. The Agent SDK's observability page uses this variable as an example of how to change the service name.Version 2.1.332 (2026-11-25) states that this variable should be set to preserve the existing service.name.

The docs column of the first row reads (Stated):

Claude Code doesn't set `gen_ai.usage.*` attributes.

The line in the CHANGELOG for version 2.1.331 reads (CHANGELOG only):

Added `gen_ai.usage.*`, `gen_ai.response.model` and `gen_ai.operation.name` to `claude_code.llm_request` trace spans; `gen_ai.usage.input_tokens` includes prompt cache tokens

Version 2.1.300 gives examples with such as, so the added attributes may not be limited to these four (Inference).

If the aggregation is based on gen_ai.usage.*, there may be versions that do not align with the calculation method described in the documentation. In sessions v2.1.331 and later, the values of gen_ai.usage.input_tokens and the value of input_tokens plus the two cache counts should be the same (Inference). Compare both values based on the received span and then determine which to use.

The safety_event section on the monitoring page and the entry for version 2.1.312 in the CHANGELOG currently match (section 4.2). The published article Where Claude Code Auto Mode Gets Its Verdict, in section 9.4, states that as of 2026-11-10, the two sources were inconsistent. The documentation was subsequently updated.

11. Frequently Asked Questions About OpenTelemetry for Claude Code

Q1. Can I configure telemetry to only collect the text of the prompts, and not the text of the responses?

Yes. You can configure this by setting both OTEL_LOG_USER_PROMPTS=1 and OTEL_LOG_ASSISTANT_RESPONSES=0. If you do not set OTEL_LOG_ASSISTANT_RESPONSES, the text of the responses will also be collected according to the OTEL_LOG_USER_PROMPTS setting. However, if you have detailed beta tracing enabled, the response.model_output attribute of the claude_code.llm_request span will still transmit the model's output according to the OTEL_LOG_USER_PROMPTS setting.

Q2. Can developers disable the telemetry that the organization has configured?

Yes, as long as the exporter values are not set in managed settings. Developers can set variables like OTEL_LOGS_EXPORTER to none in their user settings or shell. none also takes effect from the repository's project and local settings. If the exporter values are set in managed settings, neither the developer's values nor the repository's none take effect. If the destination and credentials are placed in managed settings, the developer's destination variables are cleared at startup.

Q3. Instead of safety_event, what should I look at?

Look at tool_decision. This includes decision, source, classifier_verdict, and permission_mode, which indicate that a call was rejected and from where the decision originated – whether from the settings, hook, or user. However, there are no attributes that specifically name which permission rule or setting caused the rejection. Which results and which turn ends a hook blocked, as well as proxy rejections in the sandbox, cannot be answered from the monitoring page's event tables for v2.1.312 and later (section 8.3).

Q4. When running Claude Code on Amazon Bedrock, how can I determine who initiated the action?

The organization attaches the identity itself. Since there are no Claude accounts for Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry, and because API key sessions lack Claude accounts, the attributes representing users are limited to user.id and session.id. The monitoring page describes how to include values for each user within OTEL_RESOURCE_ATTRIBUTES and distribute them through managed settings files or startup wrappers.

Q5. Does gen_ai.usage.input_tokens reach the collector?

The sources disagree. The monitoring page states that Claude Code does not set gen_ai.usage.*. However, the CHANGELOG for version 2.1.331 states that it adds gen_ai.usage.* to the span of claude_code.llm_request and that gen_ai.usage.input_tokens includes cached tokens. In either case, the calculation that adds input_tokens, cache_read_tokens, and cache_creation_tokens is applicable.

Q6. From the dashboard filtered by service.name to claude-code, the Desktop sessions have disappeared.

The service.name for local sessions in the Desktop Code tab is claude-code-desktop, starting from v2.1.332, according to the CHANGELOG. Add claude-code-desktop to the filter. The CHANGELOG mentions OTEL_SERVICE_NAME as a means of maintaining the old name, but this variable is not described in either the monitoring page or the environment variables page.

Q7. Is user.email sent by default?

It is sent if the user signs in via OAuth. The monitoring page states that user.email is only sent to the configured OTel destination and not to Anthropic. Organizations concerned about this should consider dropping or redacting this attribute on the receiving end.

Q8. If OTel is enabled, is anything sent to Anthropic?

OTel transmissions are directed to the destination(s) configured by the organization. The monitoring page states that the response text, tool arguments, and MCP names, when they are collected, are sent only to the configured destination(s). Operational telemetry sent to Anthropic is transmitted through a separate channel and can be disabled using settings such as DISABLE_TELEMETRY. When sending operational telemetry to Anthropic, all attributes with the prefix vcs.* are removed.

12. Summary

  • The monitoring page documents 8 metrics, 28 events, and 6 trace spans. When using detailed beta tracing and OTEL_LOG_USER_PROMPTS=1, an additional claude_code.system_prompt is also sent.
  • The claude_code.safety_event is no longer sent from v2.1.312. Only sessions from v2.1.307 to v2.1.311 may send this. Currently, the monitoring page's tables give no event that tells which rule rejected a call, which hooks blocked which results, or whether the sandbox proxy rejected a connection.
  • The default for OTEL_EXPORTER_OTLP_PROTOCOL is http/protobuf from v2.1.323. For gRPC on port 4317, specify grpc.
  • Prompts, responses, tool arguments and output, and API bodies are sent through six opt-in variables. With OTEL_LOG_USER_PROMPTS=1 alone, the response text is also sent. OTEL_LOG_RAW_API_BODIES includes consent to the content of OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS, and OTEL_LOG_TOOL_CONTENT.
  • Even without opting in, the OAuth user.email, organization and account IDs, and the MCP names of the Desktop's built-in servers are sent.
  • Managed settings pin the destination and credentials as a single unit. Unless the exporter choice is placed in managed settings, developers can set it to none. The OTLP endpoint in the Enterprise Admin Console takes precedence over the endpoint configured in managed settings.
  • From v2.1.282, repository settings can no longer enable telemetry, select a destination, or turn on content capture. Only off values take effect.
  • The service.name for local sessions in the Code tab on the Desktop is claude-code-desktop (according to the CHANGELOG, starting from v2.1.332). Agent SDK sessions send the same information as the CLI. For API keys and cloud provider sessions, attributes representing the user are limited to user.id and session.id.
  • There are eight discrepancies between the documentation and the CHANGELOG. gen_ai.usage.* exhibits a direct conflict; the documentation states that Claude Code does not set it, while the CHANGELOG for version 2.1.331 states that it was added. The remaining seven items are present in the CHANGELOG but lack descriptions on the monitoring page.
  • This article is based on the documentation reviewed on 2026-12-04, and Claude Code v2.1.336. Names, defaults, and what the documentation reflects may change as versions are updated.

13. References



References:
Tech Blog with curated related content

Written by Hidekazu Konishi