Claude Code
Claude Code has a built-in OpenTelemetry exporter. You turn it on and point it at Scout Trails with a handful of environment variables, set either in Claude Code’s settings file or in your shell. This page covers setup for one machine, rollout across a team, and how to change or stop what is sent.
Before you start
- An ingest key for the machine you are configuring. See Getting an ingest key.
- Outbound HTTPS access to
ingest.scoutmonitoring.ioon port 443. See Network requirements.
Set up Claude Code on your machine
The settings file is the most reliable place for the configuration: Claude Code reads it on every start, wherever you launch it from, and a value in the settings file env block takes precedence over the same variable exported in your shell.
Open
~/.claude/settings.jsonin an editor. Create the file if it doesn’t exist.Add these entries to the top-level
envobject, keeping any entries already there. Replace<your-ingest-key>with your key.{ "env": { "CLAUDE_CODE_ENABLE_TELEMETRY": "1", "OTEL_LOGS_EXPORTER": "otlp", "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", "OTEL_EXPORTER_OTLP_ENDPOINT": "https://ingest.scoutmonitoring.io:443", "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <your-ingest-key>", "OTEL_LOG_TOOL_DETAILS": "1" } }Quit any running Claude Code sessions and start a new one. Claude Code reads these variables only at startup.
Ask Claude Code to do something that uses a tool, such as listing the files in the current directory, then check the dashboard as described in Checking that data arrives.
What each variable does:
| Variable | Value | Purpose |
|---|---|---|
CLAUDE_CODE_ENABLE_TELEMETRY | 1 | Turns on Claude Code’s telemetry. Nothing is sent without it. |
OTEL_LOGS_EXPORTER | otlp | Sends Claude Code’s events, which is where tool calls and model calls come from. |
OTEL_EXPORTER_OTLP_PROTOCOL | grpc | Required. Claude Code has no default protocol, and the endpoint accepts gRPC only. |
OTEL_EXPORTER_OTLP_ENDPOINT | https://ingest.scoutmonitoring.io:443 | The Scout Trails ingest endpoint. |
OTEL_EXPORTER_OTLP_HEADERS | Authorization=Bearer <your-ingest-key> | Your ingest key. |
OTEL_LOG_TOOL_DETAILS | 1 | Includes each tool call’s arguments, such as the shell command or file path. Without it, tool calls arrive with no arguments. See What Scout Trails collects. |
Leave OTEL_METRICS_EXPORTER unset (or set it to none). Scout Trails doesn’t accept metrics, and an otlp metrics exporter pointed at the endpoint fails on every export. Leave OTEL_SERVICE_NAME unset too: the Agent column shows the service name, and Claude Code’s default is claude-code.
Using shell environment variables instead
You can export the same variables from your shell profile (~/.zshrc, ~/.bashrc) instead of using the settings file:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.scoutmonitoring.io:443
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <your-ingest-key>"
export OTEL_LOG_TOOL_DETAILS=1
Keep the double quotes around the OTEL_EXPORTER_OTLP_HEADERS value. Without them, the shell splits the value at the space after Bearer and the key is lost.
Shell variables apply only to Claude Code sessions started from a shell that has loaded them. If ~/.claude/settings.json, or a managed settings file, sets the same variable in its env block, that value wins over your shell.
Project-level configuration
Claude Code ignores OpenTelemetry exporter variables, and CLAUDE_CODE_ENABLE_TELEMETRY, in a repository’s .claude/settings.json and .claude/settings.local.json. A repository therefore can’t turn telemetry on, change where it goes, or add content such as tool arguments. Configure telemetry in your user settings, your shell, or managed settings.
A repository can turn telemetry off for itself. To stop sending events while you work in one project, add this to that project’s .claude/settings.local.json:
{
"env": {
"OTEL_LOGS_EXPORTER": "none"
}
}
This has no effect when managed settings, a --settings file, or the shell you start Claude Code from sets OTEL_LOGS_EXPORTER.
Optional settings
These variables change what Claude Code sends. Each one is off by default. Read What Scout Trails collects before turning one on: some send source code and conversation text, and the dashboard doesn’t display everything they add.
| Variable | What Claude Code adds | Shown in the dashboard |
|---|---|---|
OTEL_LOG_USER_PROMPTS=1 | The text of each prompt you type. | No. |
OTEL_LOG_RAW_API_BODIES=1 | The full request and response of every model call, including the conversation and file contents read into it. | No. |
OTEL_TRACES_EXPORTER=otlp with CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 | Trace spans for each interaction, model request and tool. | No. |
OTEL_LOG_TOOL_CONTENT=1 | Tool output (file contents, command output, diffs) as span events. Requires traces. | No. |
Every event Claude Code sends counts toward your organization’s monthly ingest allowance, including events the dashboard doesn’t display.
Roll out to a team
Each developer’s machine needs its own ingest key, so the shared part of the configuration and the key are set in different places.
Create an actor for each machine on the Actors & ingest keys tab, and give each developer the key for their machine.
Put the shared settings in Claude Code’s managed settings file, which applies to every user on the machine and can’t be overridden by user or project settings:
Operating system Managed settings file macOS /Library/Application Support/ClaudeCode/managed-settings.jsonLinux and WSL /etc/claude-code/managed-settings.jsonWindows C:\Program Files\ClaudeCode\managed-settings.json{ "env": { "CLAUDE_CODE_ENABLE_TELEMETRY": "1", "OTEL_LOGS_EXPORTER": "otlp", "OTEL_METRICS_EXPORTER": "none", "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc", "OTEL_EXPORTER_OTLP_ENDPOINT": "https://ingest.scoutmonitoring.io:443", "OTEL_LOG_TOOL_DETAILS": "1" } }Deploy the file with your device management tooling. Claude Code also accepts managed settings through MDM profiles and server-managed settings; see Anthropic’s managed settings documentation.
Each developer adds only the key to their own
~/.claude/settings.json:{ "env": { "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <their-ingest-key>" } }
Leave OTEL_EXPORTER_OTLP_HEADERS out of the managed file. A key set there would send every machine’s telemetry as the same actor. When managed settings set the endpoint, Claude Code discards any per-signal endpoint a developer sets, so developers can’t redirect the telemetry elsewhere.
Multiple machines
Configure each machine separately, each with its own actor and key. Using one key on several machines works, but their sessions and tool calls are then attributed to a single actor and can’t be separated in the dashboard. See Actors.
Change the key
- Copy the new key from the Actors & ingest keys tab.
- Replace the value after
BearerinOTEL_EXPORTER_OTLP_HEADERS, in whichever place you set it. - Restart Claude Code.
Selecting Rotate key in the dashboard invalidates the old key immediately, so every machine using it stops sending until you update it.
Turn telemetry off
- On one machine: remove the variables from
~/.claude/settings.json(or your shell profile), or setOTEL_LOGS_EXPORTERtonone, then restart Claude Code. - For one project: set
OTEL_LOGS_EXPORTERtononein that project’s settings, as shown in Project-level configuration. - From the dashboard: select Revoke key on the actor, or Deactivate the actor. Ingest rejects the key from then on. Claude Code keeps trying to send, but nothing is stored.