Skip to main content

Telemetry and Debug

These variables control what Claude Code reports and how much it logs. They turn telemetry on or off, configure OpenTelemetry (OTEL) exporters, and set debug output. Use them to opt out of reporting or to send metrics to your own collector.

This page lists 139 variables. DISABLE_TELEMETRY opts out when it has any non-empty value, even 0 or false. Unset it to turn telemetry back on. DO_NOT_TRACK=1 has the same effect. Set these in your shell or managed settings. OTEL exporter variables in project or local settings do not apply, apart from a few off values.

Example​

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
claude

Claude Code sends OTEL metrics to your local collector.

Variables​

The table is sorted by name. See Environment Variables for what each column and badge means.

VariableStatusWhat it doesValues and defaultNotes
ANTHROPIC_LOGUndocumentedThe bundled SDK reads it as the SDK log level when the client options give none.Text, level by default. The SDK checks it and falls back to its own default levelBundled SDK client. Not set from project env before trust
🧪 BETA_TRACING_ENDPOINTDocumented GatedSends detailed beta traces and logs to this OTLP/HTTP endpoint. Claude Code adds /v1/traces and /v1/logs.Text. Works only with ENABLE_BETA_TRACING_DETAILED set and when a second gate passesAll sessions. Docs say project and local settings ignore it
CCR_RUNNER_STARTUP_TIMINGUndocumented GatedPasses runner startup timing fields to Claude Code. It merges them into the startup timing record.Text. Set by the self-hosted runner for the child. Needs CLAUDE_CODE_REMOTE or CLAUDE_CODE_EMIT_STARTUP_TIMINGCloud remote and self-hosted runner sessions
CCR_SPAWN_TIMESTAMP_MSUndocumented GatedGives the spawn time in ms. Claude Code uses it to measure time from spawn to exec, first message read, and input ready.A number of milliseconds. Integer parsed with parseInt, else ignored. Set by the self-hosted runnerCloud remote and self-hosted runner sessions
CLAUDE_CODE_ACCOUNT_TAGGED_IDUndocumentedOverrides the user.account_id metric attribute.Text. Used only when OTEL_METRICS_INCLUDE_ACCOUNT_UUID is on and an account UUID exists. Else Claude Code derives a tagged idOTEL metrics. Not set from project env before trust
CLAUDE_CODE_ACTIONUndocumentedMarks a run as launched by the Claude Code GitHub Action. Claude Code reports the flag in environment metadata.On or offGitHub Action runs. Not set from project env before trust
CLAUDE_CODE_BENCH_LIVE_COUNTSUndocumentedTurns on live counts in the terminal renderer. No visible effect in a print-mode probe (Probes).On or off. Sets liveCountsEnabled on the rendererInteractive UI
CLAUDE_CODE_BYOC_ENABLE_DATADOGDocumentedOpts a BYOC environment in to a Datadog-related path. The BYOC runner passes it to the session. No visible effect in a print-mode probe (Probes).On or off. A helper returns true when CLAUDE_CODE_ENVIRONMENT_KIND is byoc and this is unsetBYOC remote sessions
CLAUDE_CODE_CLASSIFIER_SUMMARYUndocumented GatedPicks llm or heuristic summaries for the session classifier.On or off. Else a feature flag decides. A feature flag can force heuristicAll sessions, gated by a feature flag
CLAUDE_CODE_DATADOG_FLUSH_INTERVAL_MSUndocumentedSets how often the Datadog log sender flushes its batch.A number of milliseconds. Falls back to a built-in defaultDatadog event logging
CLAUDE_CODE_DD_ERROR_TRACKING_FLUSH_INTERVAL_MSUndocumentedSets how often the error tracking client sends its batch to the Datadog browser intake.A number of milliseconds, 30000 by defaultError reporting
CLAUDE_CODE_DEBUG_LOG_LEVELDocumentedSets the minimum level written to the debug log.Text, debug by default. Valid levels only, default debugAll sessions
CLAUDE_CODE_DEBUG_LOGS_DIRDocumentedSets the path of the debug log file. Despite the name it is a file path. One code branch adds <session-id>.txt to a learned directory.Text. Default ~/.claude/debug/<session-id>.txt. Debug mode must be onAll sessions
CLAUDE_CODE_DIAGNOSTICS_FILEUndocumentedSets a file that receives diagnostics events as JSON lines with a timestamp, level, event and data. Also enables extra diagnostics code.Text. Other code tests only if it is setAll sessions, also forwarded to child processes
CLAUDE_CODE_DISABLE_VITALS_EMITTERUndocumentedKill switch for the guest vitals emitter helper. It is also off in essential-traffic-only mode.On or off, off by default. The log says guest vitals are disabledGuest and container sessions
CLAUDE_CODE_EMIT_STARTUP_TIMINGUndocumentedTurns on collection and reporting of startup timing phases, as CLAUDE_CODE_REMOTE does.On or off, off by default. Reported fields include the entrypoint valueAll sessions
CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTELDocumentedRoutes the session quality survey to your own OTEL collector when Anthropic-bound traffic is blocked.On or off, off by default. When on, the survey gate no longer follows the nonessential-traffic checkAll sessions. Project env can set it before trust
CLAUDE_CODE_ENABLE_SHARE_BUNDLEUndocumentedMakes /share send the whole transcript as a feedback bundle.On or off, off by default. Used in the /share command pathFirst-party sessions
CLAUDE_CODE_ENABLE_TELEMETRYDocumented DiffersTurns on OTEL metrics and logs. Docs say project and local settings ignore it.On or off. Needs an OTEL exporter that is not noneAll sessions. Project env can set it before trust
🧪 CLAUDE_CODE_ENHANCED_TELEMETRY_BETADocumentedTurns on the enhanced tracing beta, with OTEL_TRACES_EXPORTER=otlp. ENABLE_ENHANCED_TELEMETRY_BETA is the fallback name.On or off. On-style value gives on, off-style gives off, else offAll sessions
CLAUDE_CODE_FRAME_TIMING_LOGUndocumentedAppends a JSON line with render phase timing per frame to this file.Text, off by defaultInteractive terminal UI
CLAUDE_CODE_FRAME_TIMING_SAMPLE_EVERYUndocumentedLogs memory stats for every Nth frame in the frame timing log.A number. Whole number, minimum 1 after fallback. Used only with CLAUDE_CODE_FRAME_TIMING_LOGInteractive terminal UI
CLAUDE_CODE_GB_DISK_CACHE_WHEN_TELEMETRY_OFFUndocumentedKeeps the GrowthBook disk cache on when telemetry is off.On or off, off by default. Needs DISABLE_GROWTHBOOK unsetFirst-party sessions
CLAUDE_CODE_HOST_PLATFORMUndocumentedReports the host platform in the environment record. A host app can set it when the host OS differs from the build.Text. Also exposed as hostPlatform in a policy facts objectAll sessions
CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTHDocumentedCaps the length of content-bearing OpenTelemetry attributes. Truncated text gets a [TRUNCATED - Content exceeds ...] marker.A number, 61440 by default. Whole number of 1 or more in plain digits. The code takes the smallest of it and the three OTEL_*_ATTRIBUTE_VALUE_LENGTH_LIMIT varsAll sessions, when OTEL content logging is on
CLAUDE_CODE_OTEL_DIAG_STDERRDocumentedWrites OpenTelemetry exporter diagnostic errors to stderr. Without it they go only to the debug log.On or off. Claude Code removes it from the env of shell tool subprocessesAll sessions
CLAUDE_CODE_OTEL_FLUSH_TIMEOUT_MSDocumentedSets how long Claude Code waits to flush pending OpenTelemetry data.A number of milliseconds, 5000 by default. Whole number in ms. The trace flush gets half of the valueAll sessions, when OTEL is on
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MSDocumentedSets how long the output of the OTEL headers helper stays cached before a refresh.A number of milliseconds. Whole number in ms. Docs default is 1740000All sessions, when an OTEL headers helper is set
CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MSDocumentedSets how long the OpenTelemetry exporters get to finish at exit.A number of milliseconds, 2000 by default. Whole number in ms. The exporter timeout caps it at an internal maximum and subtracts 250 msAll sessions, when OTEL is on
CLAUDE_CODE_PERFETTO_TRACEUndocumentedThe only read site logs [Perfetto] initializePerfettoTracing called, env value:. No visible effect in a print-mode probe (Probes).Text. The code that turns it on is not shownAll sessions
CLAUDE_CODE_PROFILE_QUERYUndocumentedTurns on query profiling. The report shows TTFT, pre-request overhead, and network latency.Set to 1. Without it a message says Query profiling not enabledAll sessions
CLAUDE_CODE_PROFILE_STARTUPUndocumentedTurns on startup profiling marks. Without it a random sample of runs (5 percent in one profiler and 0.5 percent in another) is profiled.On or off. Memory snapshots are part of the reportAll sessions
CLAUDE_CODE_PROPAGATE_TRACEPARENTDocumentedSends the W3C traceparent header on custom proxy URLs.On or off. The check is true for direct Anthropic API use or when this var is setAll sessions
CLAUDE_CODE_SESSION_LOGUndocumentedGives the log path that is written into the concurrent-session pid file record.Text. Only stored as logPath in the recordConcurrent-session registry
CLAUDE_CODE_SLOW_OPERATION_THRESHOLD_MSUndocumentedSets the ms threshold for slow-operation timing around calls such as JSON.stringify.A number of milliseconds. The default is no limit (Infinity)All sessions
CLAUDE_CODE_SPAWN_TIMESTAMP_MSUndocumentedGives the time the process was spawned, in ms. The headless profiler uses it as the start for startup timing.A number of milliseconds. Integer. CCR_SPAWN_TIMESTAMP_MS is checked firstHeadless and print mode
CLAUDE_CODE_TAGSUndocumentedAdds a tags string to the environment info that Claude Code sends with its telemetry.TextAll sessions
CLAUDE_CODE_TRIGGER_IDUndocumentedPasses a trigger ID into a feature flag event as trigger_id.Text. No other effect seenAll sessions
CLAUDE_CODE_WORKSPACE_HOST_PATHSUndocumentedAdds host paths to each event as workspace.host_paths.Text. Split on the pipe character into a listHosted workspaces
CLAUDE_DEBUGUndocumentedLogs Node process warnings to the debug log.On or offAll sessions
CLAUDE_PTY_RECORDUndocumentedNames a file where the PTY host records the terminal output of its child.--
DEBUGDocumentedTurns on debug mode when truthy.--
DEBUG_CLAUDE_AGENT_SDKUndocumentedIn the SDK, forwards the CLI stderr to the caller and sets DEBUG to 1 for the child.--
DEBUG_SDKUndocumentedTurns on debug mode at launch.--
DISABLE_ERROR_REPORTINGDocumentedOpts out of error reporting.On or off-
DISABLE_TELEMETRYDocumentedOpts out of telemetry. The bundle also treats it as "no-telemetry" mode for other non-essential traffic checks.Text. Any non-empty string counts, so 0 and false still opt out. Passed on to remote child sessionsAll sessions. Not set from project env before trust
DO_NOT_TRACKDocumentedOpts out of telemetry like DISABLE_TELEMETRY does.On or off. Parsed as a standard boolean, so 0 or false leaves telemetry onAll sessions. Not set from project env before trust
🧪 ENABLE_BETA_TRACING_DETAILEDDocumented GatedTurns on detailed beta tracing. It needs BETA_TRACING_ENDPOINT as well.On or off. Also needs a non-empty BETA_TRACING_ENDPOINT. Gated by an org check or a feature flagTracing. Not set from project env before trust
ENABLE_ENHANCED_TELEMETRY_BETADocumentedTurns on enhanced telemetry tracing. It is the fallback name of CLAUDE_CODE_ENHANCED_TELEMETRY_BETA.On or off. Truthy values enable it. The CLAUDE_CODE_ name is read first with ??Tracing. Not set from project env before trust
GITHUB_ACTION_INPUTSUndocumentedPasses the action inputs to a startup telemetry field named githubActionInputs.TextGitHub Actions. Not set from project env before trust
GITHUB_ACTOR_IDUndocumentedSends the actor id as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GITHUB_EVENT_NAMEUndocumentedSends the event name as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GITHUB_REPOSITORYUndocumentedSends the repository name as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GITHUB_REPOSITORY_IDUndocumentedSends the repository id as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GITHUB_REPOSITORY_OWNERUndocumentedSends the repository owner as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GITHUB_REPOSITORY_OWNER_IDUndocumentedSends the repository owner id as telemetry metadata when GITHUB_ACTIONS is on.TextGitHub Actions. Not set from project env before trust
GOOGLE_SDK_NODE_LOGGINGUndocumentedTurns on debug logging in the bundled Google libraries when it is set.On or offGoogle auth library
OTEL_ATTRIBUTE_COUNT_LIMITUndocumentedOTel SDK limit for the attribute count per log record and span.A number-
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMITDocumentedSets the OTel limit for attribute value length. Claude Code caps content attributes at the smaller limit.A number-
OTEL_BLRP_EXPORT_TIMEOUTUndocumentedOTel log record batch processor: export timeout in ms.--
OTEL_BLRP_MAX_EXPORT_BATCH_SIZEUndocumentedOTel log record batch processor: max records per export.A number-
OTEL_BLRP_MAX_QUEUE_SIZEUndocumentedOTel log record batch processor: queue size.A number-
OTEL_BLRP_SCHEDULE_DELAYUndocumentedOTel log record batch processor: delay between exports in ms.--
OTEL_BSP_EXPORT_TIMEOUTUndocumentedOTel span batch processor: export timeout in ms.--
OTEL_BSP_MAX_EXPORT_BATCH_SIZEUndocumentedOTel span batch processor: max spans per export.A number-
OTEL_BSP_MAX_QUEUE_SIZEUndocumentedOTel span batch processor: queue size.A number-
OTEL_BSP_SCHEDULE_DELAYUndocumentedOTel span batch processor: delay between exports in ms.--
OTEL_EXPORTER_OTLP_CERTIFICATEDocumentedGives the root CA file for the OTLP exporter. Signal-specific vars win.--
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATEDocumentedGives the client certificate file for OTLP mutual TLS.--
OTEL_EXPORTER_OTLP_CLIENT_KEYDocumentedGives the client private key file for OTLP mutual TLS.Text (a secret)-
OTEL_EXPORTER_OTLP_COMPRESSIONUndocumentedSets OTLP compression. Signal-specific vars win.--
OTEL_EXPORTER_OTLP_ENDPOINTDocumentedSets the OTLP collector endpoint for metrics, logs, and traces.A URL-
OTEL_EXPORTER_OTLP_HEADERSDocumentedSets extra OTLP request headers as key=value pairs.--
OTEL_EXPORTER_OTLP_INSECUREUndocumentedMakes the gRPC OTLP exporter use an insecure channel when the value is true.--
OTEL_EXPORTER_OTLP_LOGS_CERTIFICATEUndocumentedGives the root CA file for the OTLP logs exporter.--
OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATEUndocumentedGives the client certificate file for the OTLP logs exporter.--
OTEL_EXPORTER_OTLP_LOGS_CLIENT_KEYUndocumentedGives the client key file for the OTLP logs exporter.Text (a secret)-
OTEL_EXPORTER_OTLP_LOGS_COMPRESSIONUndocumentedSets OTLP compression for logs only.--
OTEL_EXPORTER_OTLP_LOGS_ENDPOINTDocumentedSets the OTLP endpoint for logs only.A URL-
OTEL_EXPORTER_OTLP_LOGS_HEADERSDocumentedSets OTLP headers for logs only.--
OTEL_EXPORTER_OTLP_LOGS_INSECUREUndocumentedMakes the gRPC OTLP logs exporter use an insecure channel when true.--
OTEL_EXPORTER_OTLP_LOGS_PROTOCOLDocumentedChooses the OTLP protocol for logs. Falls back to OTEL_EXPORTER_OTLP_PROTOCOL.--
OTEL_EXPORTER_OTLP_METRICS_CERTIFICATEUndocumentedGives the root CA file for the OTLP metrics exporter.--
OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATEUndocumentedGives the client certificate file for the OTLP metrics exporter.--
OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEYDocumentedGives the client key file for the OTLP metrics exporter.Text (a secret)-
OTEL_EXPORTER_OTLP_METRICS_COMPRESSIONUndocumentedSets OTLP compression for metrics only.--
OTEL_EXPORTER_OTLP_METRICS_ENDPOINTDocumentedSets the OTLP endpoint for metrics only.A URL-
OTEL_EXPORTER_OTLP_METRICS_HEADERSDocumentedSets extra HTTP headers on the OTLP metrics export.Text. Overrides OTEL_EXPORTER_OTLP_HEADERSMetrics exporter with http/json, http/protobuf or grpc. Ignored in project and local env
OTEL_EXPORTER_OTLP_METRICS_INSECUREUndocumentedAllows an insecure (non-TLS) connection for the OTLP metrics exporter.TextMetrics exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_METRICS_PROTOCOLDocumentedPicks the OTLP wire protocol for metrics. Falls back to OTEL_EXPORTER_OTLP_PROTOCOL.Text. Another value throws an Unknown protocol errorMetrics exporter when OTEL_METRICS_EXPORTER has otlp. Ignored in project and local env
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCEDocumentedChooses delta or cumulative temporality for exported OTLP metrics.Text. When unset, Claude Code sets it to delta at telemetry start (set by Claude Code)Metrics exporter. Project env can set it before trust
OTEL_EXPORTER_OTLP_PROTOCOLDocumentedSets the default OTLP wire protocol for metrics, logs and traces.Text. A per-signal ..._PROTOCOL winsTelemetry exporters with otlp. Ignored in project and local env
OTEL_EXPORTER_OTLP_TIMEOUTUndocumentedSets the OTLP export timeout in ms for every signal.A number. A per-signal OTEL_EXPORTER_OTLP_<SIGNAL>_TIMEOUT wins. A bad value logs a warningOTLP exporters. Not set from project env before trust
OTEL_EXPORTER_OTLP_TRACES_CERTIFICATEUndocumentedSets the root CA file that the OTLP traces exporter trusts.Falls back to OTEL_EXPORTER_OTLP_CERTIFICATE. A read failure logs a warningTraces exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATEUndocumentedSets the client certificate file for mTLS on the OTLP traces exporter.Falls back to OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE. Needs the matching client keyTraces exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEYUndocumentedSets the client private key file for mTLS on the OTLP traces exporter.Text (a secret). Falls back to OTEL_EXPORTER_OTLP_CLIENT_KEY. Needs the matching client certificateTraces exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_TRACES_COMPRESSIONUndocumentedSets the compression of OTLP trace requests.Text. Another value logs a warning and is ignored. Falls back to OTEL_EXPORTER_OTLP_COMPRESSIONTraces exporter. Project env can set it before trust
OTEL_EXPORTER_OTLP_TRACES_ENDPOINTDocumented GatedSets the OTLP traces endpoint URL. A valid value in remote mode also forces http/protobuf for traces.Text. The remote check needs https or localhost http, no credentials, no query, and a path that ends in tracesTraces exporter. Remote check needs CLAUDE_CODE_REMOTE. Not set from project env before trust
OTEL_EXPORTER_OTLP_TRACES_HEADERSDocumentedSets extra HTTP headers on the OTLP traces export.Text. Overrides OTEL_EXPORTER_OTLP_HEADERSTraces exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_TRACES_INSECUREUndocumentedAllows an insecure (non-TLS) connection for the OTLP traces exporter.TextTraces exporter. Ignored in project and local env
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLDocumentedPicks the OTLP wire protocol for traces. Falls back to OTEL_EXPORTER_OTLP_PROTOCOL.Text. A valid remote OTEL_EXPORTER_OTLP_TRACES_ENDPOINT forces http/protobufTraces exporter when OTEL_TRACES_EXPORTER has otlp. Ignored in project and local env
OTEL_EXPORTER_PROMETHEUS_HOSTDocumentedSets the host that the Prometheus metrics exporter binds to.Falls back to the SDK defaultMetrics exporter with prometheus. Ignored in project and local env
OTEL_EXPORTER_PROMETHEUS_PORTDocumentedSets the port that the Prometheus metrics exporter listens on.A number, port by default. Falls back to the SDK default portMetrics exporter with prometheus. Ignored in project and local env
OTEL_LOG_ASSISTANT_RESPONSESDocumentedIncludes the model response text in assistant_response log events.On, off, or unset. When unset, the value of OTEL_LOG_USER_PROMPTS applies. 0 keeps responses redactedAll entrypoints. Ignored in project and local env. Project env may set only an off value
OTEL_LOG_MANAGED_SETTINGSDocumentedAdds redacted managed settings and a SHA-256 digest to managed_settings_resolved events.On or off. Reads managed and user layers first, and skips project and local scopesAll entrypoints. Ignored in project and local env
OTEL_LOG_RAW_API_BODIESDocumentedLogs raw Messages API request and response JSON as events.Off by default. 1 (bool values) means inline. file:<dir> writes full bodies to disk with a body_refAll entrypoints, not diskless hosts. Ignored in project and local env
OTEL_LOG_TOOL_CONTENTDocumentedIncludes tool content in the tool.output span event.On or off. Needs tracing onAll entrypoints with tracing. Ignored in project and local env. Project env may set only an off value
OTEL_LOG_TOOL_DETAILSDocumentedIncludes tool input, MCP server names, raw errors and similar details in telemetry.On or off. It also adds classifier_category on tool_decision eventsAll entrypoints. Ignored in project and local env. Project env may set only an off value
OTEL_LOG_USER_PROMPTSDocumentedIncludes user prompt text in OpenTelemetry traces and logs.On or off. Off by default, so prompts show as <REDACTED>All entrypoints. Ignored in project and local env. Project env may set only an off value
OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMITUndocumentedLimits the number of attributes on each OTLP log record.A number. Falls back to OTEL_ATTRIBUTE_COUNT_LIMIT, then 128Log exporters. Not set from project env before trust
OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMITDocumentedLimits the length of each log record attribute value. Also lowers the content cut-off for prompts and tool content.A number, unlimited by default. Integer, min 0, default unlimited. The content cut-off is the lowest of this, the span and general limits, and CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTH (61440)Log exporters and OTEL content fields. Not set from project env before trust
OTEL_LOGS_EXPORT_INTERVALDocumentedSets the log batch export delay in ms.A number, 5000 by default. Integer. The first-party event logger reads it too (default 10000 from the process env)Log exporters. Project env can set it before trust
OTEL_LOGS_EXPORTERDocumentedChooses the exporters for OpenTelemetry log events.A comma-separated list. Needs CLAUDE_CODE_ENABLE_TELEMETRY. In stream-json output mode Claude Code removes console from itAll entrypoints. Project settings may only set none. Ignored in project and local env
OTEL_METRIC_EXPORT_INTERVALDocumentedSets the metric export interval in ms for the OTLP and console readers.A number, 60000 by default. IntegerMetrics exporters. Project env can set it before trust
OTEL_METRICS_EXPORTERDocumentedChooses the exporters for OpenTelemetry metrics.A comma-separated list. Needs CLAUDE_CODE_ENABLE_TELEMETRY. In stream-json output mode console is removedAll entrypoints. Project settings may only set none. Ignored in project and local env
OTEL_METRICS_INCLUDE_ACCOUNT_UUIDDocumentedAdds the account UUID (and a tagged id) to metric attributes.On or off, on by default. Any set value is parsed as bool, so only 1, true, yes, on keep itMetrics. Project env can set it before trust
OTEL_METRICS_INCLUDE_ENTRYPOINTDocumentedAdds the session entrypoint as app.entrypoint to metric attributes.On or off, off by default. Any set value is parsed as boolMetrics. Project env can set it before trust
OTEL_METRICS_INCLUDE_REPOSITORYDocumentedAdds vcs.* repository attributes to metrics and events.On or off, off by default. Any set value is parsed as boolMetrics and events. Project env can set it before trust
OTEL_METRICS_INCLUDE_RESOURCE_ATTRIBUTESDocumentedAdds OTEL_RESOURCE_ATTRIBUTES keys to metric attributes.On or off, on by default. Any set value is parsed as bool. user. and identity. keys are skipped when the host supplies identityMetrics. Project env can set it before trust
OTEL_METRICS_INCLUDE_SESSION_IDDocumentedAdds session.id (and the remote session id) to metric attributes.On or off, on by default. Any set value is parsed as boolMetrics. Project env can set it before trust
OTEL_METRICS_INCLUDE_VERSIONDocumentedAdds the Claude Code version as app.version to metric attributes.On or off, off by default. Any set value is parsed as boolMetrics. Project env can set it before trust
OTEL_RESOURCE_ATTRIBUTESDocumentedAdds custom resource attributes to telemetry, and to metric labels.Text. Bad pairs are droppedAll entrypoints. Project env can set it before trust
OTEL_SERVICE_NAMEUndocumentedSets the service.name resource attribute of exported telemetry.TextTelemetry. Project env can set it before trust
OTEL_SPAN_ATTRIBUTE_COUNT_LIMITUndocumentedLimits the attributes on each span.A number. Falls back to OTEL_ATTRIBUTE_COUNT_LIMIT, then 128Tracing. Not set from project env before trust
OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMITUndocumentedLimits the attributes on each span event.A number, 128 by defaultTracing. Not set from project env before trust
OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMITUndocumentedLimits the attributes on each span link.A number, 128 by defaultTracing. Not set from project env before trust
OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMITDocumentedLimits the length of span attribute values. Also lowers the content cut-off.A number, unlimited by default. Integer, min 0, default unlimited. The content cut-off is the lowest of this, the log and general limits, and CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTHTracing and OTEL content fields. Not set from project env before trust
OTEL_SPAN_EVENT_COUNT_LIMITUndocumentedLimits the events on each span.A number, 128 by defaultTracing. Not set from project env before trust
OTEL_SPAN_LINK_COUNT_LIMITUndocumentedLimits the links on each span.A number, 128 by defaultTracing. Not set from project env before trust
OTEL_TRACES_EXPORT_INTERVALDocumentedSets the trace batch export delay in ms.A number, 5000 by default. IntegerTraces exporters. Project env can set it before trust
OTEL_TRACES_EXPORTERDocumentedChooses the exporters for OpenTelemetry traces.A comma-separated list. Needs telemetry and tracing on. In stream-json output mode console is removedAll entrypoints. Project settings may only set none. Ignored in project and local env
OTEL_TRACES_SAMPLERUndocumentedChooses the trace sampler.Text, parentbased_always_on by defaultTracing. Not set from project env before trust
OTEL_TRACES_SAMPLER_ARGUndocumentedSets the sampling ratio for the traceidratio samplers.A number. Blank or out of range logs an error and uses 1Tracing with a ratio sampler. Not set from project env before trust
SRT_DEBUGUndocumentedTurns on [SandboxDebug] log lines in the bundled sandbox runtime.Any non-empty value turns it on. Level picks console.error, console.warn, or logSandbox runtime
SWE_BENCH_INSTANCE_IDUndocumentedSends the SWE-bench instance id in event metadata.Text. Empty string when unset. Goes into the event fields (sweBenchInstanceId)All sessions, telemetry only
SWE_BENCH_RUN_IDUndocumentedSends the SWE-bench run id in event metadata.Text. Empty string when unset. Goes into the event fields (sweBenchRunId)All sessions, telemetry only
SWE_BENCH_TASK_IDUndocumentedSends the SWE-bench task id in event metadata.Text. Empty string when unset. Goes into the event fields (sweBenchTaskId)All sessions, telemetry only
TRACEPARENTDocumentedParent trace context. Claude Code uses it as the parent of its OTEL spans.Text. Non-empty W3C traceparent string. Used only when a tracing gate is onAll sessions, when OTEL tracing is on
TRACESTATEDocumentedTrace state that goes with TRACEPARENT. It is passed to the OTEL propagator.Text. Only used when TRACEPARENT is set and tracing is onAll sessions, when OTEL tracing is on

How It Works​

Telemetry features read their variables once at startup, so a change to env in a settings file needs a relaunch. DISABLE_TELEMETRY and DO_NOT_TRACK also turn off feature-flag fetching, so features that depend on server flags stop working. The official docs list the affected features under Features That Need Feature-Flag Fetching.

Source: the program (variable names found in the 2.1.304 binary) and the Environment Variables page of the official docs.