Claude Code OpenTelemetry setup
Claude Code sends its OpenTelemetry telemetry to the collection address we give you, as soon as your administrator turns it on. There is nothing to install: it is a Claude Code setting, made from the claude.ai console without touching workstations. For Claude usage in companies, seats and agents included, see Claude for business.
What you need
Section titled “What you need”- An up-to-date Claude Code on developers’ workstations, signed in to the organization’s Claude Team or Claude Enterprise account.
- The owner or primary owner of the claude.ai organization, to set the managed settings.
- The collection address and access token we give you at the start of the audit.
The variables
Section titled “The variables”| Variable | Value | Role |
|---|---|---|
CLAUDE_CODE_ENABLE_TELEMETRY |
1 |
Turns telemetry on. |
OTEL_LOGS_EXPORTER |
otlp |
Sends events. |
OTEL_METRICS_EXPORTER |
otlp |
Sends metrics. |
OTEL_EXPORTER_OTLP_PROTOCOL |
grpc |
The collection address’s protocol. |
OTEL_EXPORTER_OTLP_ENDPOINT |
the address given | Where the data goes. |
OTEL_EXPORTER_OTLP_HEADERS |
Authorization=Bearer … |
The access token given. |
OTEL_LOG_USER_PROMPTS |
1 |
Adds the text of requests; without it, the Cockpit cannot read use cases. |
OTEL_LOG_ASSISTANT_RESPONSES |
1 |
Adds the text of responses. |
OTEL_RESOURCE_ATTRIBUTES |
department=… |
The workstation’s department, to read results by department. No spaces in the value. |
The steps
Section titled “The steps”-
Write the managed settings
In the claude.ai console, the owner opens “Organization settings”, then “Claude Code”, then “Managed settings”. They put the variables in the
envblock and save. The settings reach every member of the organization at their next Claude Code launch.{"env": {"CLAUDE_CODE_ENABLE_TELEMETRY": "1","OTEL_LOGS_EXPORTER": "otlp","OTEL_METRICS_EXPORTER": "otlp","OTEL_EXPORTER_OTLP_PROTOCOL": "grpc","OTEL_EXPORTER_OTLP_ENDPOINT": "<collection address>","OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Bearer <token>","OTEL_LOG_USER_PROMPTS": "1","OTEL_LOG_ASSISTANT_RESPONSES": "1","OTEL_RESOURCE_ATTRIBUTES": "department=<department>"}} -
Have the collection address accepted
At their next Claude Code launch, each developer sees a window that names the collection address, and accepts it once. Claude Code asks for this consent for any sending address set remotely; if the developer declines, Claude Code closes.
-
Check that data arrives
After a first Claude Code session, the Cockpit’s Data sources screen shows the source and the date of its last send.
Without the console: the file on workstations
Section titled “Without the console: the file on workstations”Console settings do not reach a Claude Code session that goes through Amazon Bedrock, Google Cloud or Microsoft Foundry, or one signed in with a Claude Console API key. In those cases, or if you already manage workstations with a management tool, put the same env block in Claude Code’s managed settings file, then deploy it to workstations. The file’s location for each system is in Anthropic’s documentation on managed settings.
What is measured, and what is not
Section titled “What is measured, and what is not”- Measured: each request and each response, the model calls with the model, tokens, estimated cost and duration, and the department if
OTEL_RESOURCE_ATTRIBUTESgives it. - Not retroactive: measurement starts when telemetry is turned on; earlier sessions cannot be retrieved.
- Not covered: conversations in claude.ai and the Claude app, which have their own claude.ai connector.
Frequently asked questions
Section titled “Frequently asked questions”Does the data go through Anthropic?
Section titled “Does the data go through Anthropic?”No. Telemetry goes from the workstation to the collection address set in the settings; it does not go through Anthropic.
Isn’t the Claude Code Analytics API enough?
Section titled “Isn’t the Claude Code Analytics API enough?”It gives counters per person and per day: sessions, lines of code, commits, cost. It does not say what the sessions are for. Telemetry gives the requests themselves, and use cases are drawn from them.
To see what the tool shows on your own tools, book a call.