Send Claude Code and Cowork Telemetry to KloudMate
Claude Code and Cowork can export OpenTelemetry data to KloudMate, so you can track sessions, token usage, cost, tool use, and errors for every developer in your organization. Claude Code exports metrics, events, and traces. Cowork, in Claude Desktop, exports events.
| Where Claude runs | Where you configure it | service.name in KloudMate |
|---|---|---|
| Claude Code in the terminal or an IDE | ~/.claude/settings.json, or managed settings for a team | claude-code |
| Claude Desktop, Code tab | The same settings as Claude Code | claude-code-desktop |
| Claude Desktop, Cowork tab | Organization settings → Cowork on claude.ai | cowork |
To trace your own application’s calls to the Claude API instead, see Send Claude API Traces to KloudMate.
Prerequisites
Section titled “Prerequisites”- A KloudMate workspace API key, from Settings → Ingest Keys. When you roll the configuration out to a team, the key is copied to every developer’s machine, so create a dedicated ingest key for it.
- To configure a team, the Owner or Primary Owner role in a Claude for Teams or Claude for Enterprise organization.
Send Claude Code telemetry from your machine
Section titled “Send Claude Code telemetry from your machine”Claude Code reads its telemetry settings from environment variables. Put them in the env block of ~/.claude/settings.json, so they apply to every Claude Code session on your machine, including the IDE extensions and the Code tab in Claude Desktop:
Replace YOUR_KLOUDMATE_API_KEY with your KloudMate API key. KloudMate expects the raw key in the Authorization header, with no Bearer prefix.
If the KloudMate agent runs on the same machine, set OTEL_EXPORTER_OTLP_ENDPOINT to http://localhost:4318 and leave out OTEL_EXPORTER_OTLP_HEADERS. The agent forwards the data with your workspace’s API key.
Claude Code reads the settings when a session starts, so restart Claude Code, or start a new session in Claude Desktop. Within a minute, data appears in KloudMate under the service claude-code, or claude-code-desktop for a Code tab session.
Turn on traces
Section titled “Turn on traces”Traces are in beta. Add these variables to the same env block to export a trace for each prompt, with a span for each model request and each tool use:
Each prompt then appears in AI Observability as a Claude Code Turn, with its model calls, tool calls, tokens, and estimated cost. To see the prompt text in the turn, also set OTEL_LOG_USER_PROMPTS=1. See Choose what content is exported.
Roll out to your team
Section titled “Roll out to your team”As an Owner of a Claude for Teams or Claude for Enterprise organization, you can deliver the configuration to every developer from claude.ai, with no change on their machines.
1. On claude.ai, go to Organization settings → Claude Code → Managed settings.
2. Add the telemetry settings, with a resource attribute that identifies the team:
3. Save. Claude Code picks up the settings the next time each developer starts it. Because the settings set an export endpoint, Claude Code asks each developer to approve them once, in their next interactive terminal session.
Managed settings take precedence over each developer’s own settings, so developers can’t point the export somewhere else. They reach sessions that sign in with the organization’s Team or Enterprise account. Sessions that authenticate with a Claude Console API key, or that use Amazon Bedrock, Google Cloud, or Microsoft Foundry, don’t receive them.
For those sessions, or if you manage devices with MDM, deploy the same JSON as a managed-settings.json file instead:
/Library/Application Support/ClaudeCode/managed-settings.json, or the com.anthropic.claudecode managed preferences domain in a configuration profile.
/etc/claude-code/managed-settings.json
C:\Program Files\ClaudeCode\managed-settings.json, or a REG_SZ value named Settings under HKLM\SOFTWARE\Policies\ClaudeCode that holds the JSON.
OTEL_RESOURCE_ATTRIBUTES adds its keys to every metric and event, so you can group cost and usage by team in KloudMate. Values can’t contain spaces.
Send Cowork events
Section titled “Send Cowork events”Cowork exports events, not metrics or traces, and it has its own settings. It’s available on the Team and Enterprise plans, and needs Claude Desktop 1.1.4173 or later for local sessions, or 1.22209.3 or later for cloud sessions. See Monitor Claude Cowork activity with OpenTelemetry.
1. On claude.ai, go to Organization settings → Cowork.
2. Fill in the OpenTelemetry fields:
| Field | Value |
|---|---|
| OTLP endpoint | https://otel.kloudmate.com:4318 |
| OTLP protocol | HTTP/protobuf |
| OTLP headers | Authorization=YOUR_KLOUDMATE_API_KEY |
3. Save. Cowork reads the settings when a session starts, so the events arrive from the next Cowork session each user starts.
Cowork events arrive in KloudMate Logs under the service cowork.
Choose what content is exported
Section titled “Choose what content is exported”By default, Claude Code and Cowork export metadata only: counts, durations, models, tokens, cost, and tool names. Prompt text, responses, and tool arguments are redacted. To include them in Claude Code, add these variables to the env block:
| Variable | Adds |
|---|---|
OTEL_LOG_USER_PROMPTS=1 | Prompt text, and model response text unless you set OTEL_LOG_ASSISTANT_RESPONSES=0 |
OTEL_LOG_TOOL_DETAILS=1 | Tool arguments, such as Bash commands and file paths, and MCP server and tool names, on events |
OTEL_LOG_TOOL_CONTENT=1 | Tool output, as an event on trace spans. Requires traces. |
Claude’s answers, and tool arguments and results on trace spans, need Claude Code’s detailed beta tracing, which is configured separately. See Claude Code monitoring.
For Cowork, content is set on each device with the otlpContentCapture key of the Claude Desktop managed configuration. To make sure every device sends metadata only, set it to [].
Even with metadata only, events carry user.email when developers sign in with a Claude account, and Cowork events carry the paths of the folders a user connects. Content you turn on is stored in KloudMate under your workspace’s retention settings.
What you get in KloudMate
Section titled “What you get in KloudMate”Metrics and events carry the developer’s account, so you can break cost and token usage down by developer in Explore or a dashboard. Cost values are estimates. For billing, use your billing dashboard. For every metric, event, and attribute, see Claude Code monitoring and Cowork monitoring.
Troubleshooting
Section titled “Troubleshooting”| Problem | What to check |
|---|---|
| No data from Claude Code | Check that CLAUDE_CODE_ENABLE_TELEMETRY is 1 and OTEL_EXPORTER_OTLP_PROTOCOL is set, because it has no default. Run claude --debug-file /tmp/claude.log and search the log for [3P telemetry] errors. |
| Export errors with status 401 | OTEL_EXPORTER_OTLP_HEADERS doesn’t hold a valid KloudMate API key, or the value has a Bearer prefix. |
| Managed settings don’t apply | Run claude doctor and read the Managed settings (remote) line. Exporter changes apply only when Claude Code restarts. |
| No data from the Claude Desktop Code tab | Put the variables in ~/.claude/settings.json or managed settings, not in your shell profile. Filter KloudMate by the service claude-code-desktop, not claude-code. |
| No Cowork events | Start a new Cowork session after you save, and check that Claude Desktop is version 1.1.4173 or later, or 1.22209.3 or later for cloud sessions. |