Skip to main content
All Claude Code integration capabilities

About

Ship Claude Code session telemetry to Sazabi using Claude Code’s built-in OTLP exporter. Once configured, every session emits structured events covering user prompts, tool calls, tool results, and model API requests with token counts and cost — no code changes to your projects required. Events include attributes like claude_code.user_prompt, claude_code.tool_result, and claude_code.api_request, along with prompt, model, session.id, user.email, token counts, and cost per API call.
Enabling OTEL_LOG_USER_PROMPTS=1 exports raw prompt text, including any sensitive content typed during sessions. Keep this off unless you understand the privacy implications for your team.

Prerequisites

  • One or more places Claude Code runs:
    • The Claude Code CLI on a developer’s machine
    • Claude Code on the web, in a Claude for Teams or Enterprise organization where you are an Owner
    • The Claude Code GitHub Action in a repository where you can add Actions secrets
  • Your Sazabi intake URL, shown above — open the log source and copy the Intake URL from its setup screen (the public key is embedded in the URL)

Set up in the dashboard

Claude Code reads its telemetry settings from a different place on each surface. Set up each surface you use; they can all send to the same log source. Every surface uses the same variables. OTEL_METRICS_INCLUDE_ENTRYPOINT tags events with app.entrypoint (how the session was launched) and OTEL_METRICS_INCLUDE_REPOSITORY tags them with the session repository’s vcs.repository.name, vcs.owner.name, and vcs.repository.url.full (Claude Code v2.1.269 or later), so you can filter and group by surface and repository. Leave OTEL_LOG_ASSISTANT_RESPONSES at 0 — when it is unset, it falls back to the prompts setting, so enabling prompts alone would also export model responses. The setup sends logs only. Sazabi stores each metric data point as a log record and isn’t a metrics store, so leave OTEL_METRICS_EXPORTER unset to keep volume down.

Claude Code CLI

1

Add OTEL environment variables to Claude Code settings

Open or create ~/.claude/settings.json and add the following variables to the env block:
~/.claude/settings.json
Replace <your intake URL> with the intake URL shown above.
2

Restart Claude Code

Claude Code loads settings at startup. Quit and relaunch Claude Code for the new environment variables to take effect.

Claude Code on the web

1

Add OTEL environment variables to server-managed settings

In the claude.ai console, open Organization settings > Claude Code > Managed settings and add the same env block shown for the CLI, with your intake URL as OTEL_EXPORTER_OTLP_ENDPOINT. Save the settings.Server-managed settings apply to every member of your Claude organization, on their machines as well as in cloud sessions, and take precedence over their own settings.
2

Allow cloud sessions to reach Sazabi

Cloud sessions send telemetry through their cloud environment’s network, and the default Trusted network access level blocks your intake URL. On claude.ai/code, open the settings of each cloud environment your sessions use, set Network access to Custom, and add the hostname of your intake URL (without https://) to Allowed domains. Keep the default package-manager list selected if your sessions install packages.Each environment keeps its own allowlist, and no managed setting can add a domain to it. Environments with Full network access need no change.
3

Start a new cloud session

Managed settings load when a session starts. Telemetry begins with the next cloud session you start on claude.ai/code.

Claude Code GitHub Actions

1

Store the intake URL as a repository secret

Save your intake URL as the SAZABI_OTLP_ENDPOINT Actions secret in each repository that runs the action, so the workflow file never carries it:
2

Enable telemetry on the action step

Add an env block and a settings input to each anthropics/claude-code-action step. The action passes only CLAUDE_CODE_ENABLE_TELEMETRY and the OTEL_EXPORTER_*, OTEL_LOGS_EXPORTER, and OTEL_RESOURCE_ATTRIBUTES variables through to Claude Code, so the remaining variables go in the settings input:
.github/workflows/claude.yml
Keep the step’s other inputs, such as prompt and claude_args. If the step already has a settings input, add these keys to its env block.
3

Commit the workflow

Commit the workflow change and open a pull request. Telemetry begins with the next workflow run.

Set up with the CLI

You can also register the Claude Code log source with the Sazabi CLI (installed and authenticated — see CLI reference). Registering the source mints the same intake URL the dashboard shows above (the public key is embedded in its hostname):
The command prints the intake URL for the new source — copy the whole URL and point your sender at it using the configuration shown above. Run sazabi log-sources get <log-source-id> at any time to reprint the endpoint, or sazabi log-sources list to see every log source in the project.

Verify

Start a Claude Code session — or a cloud session on claude.ai/code, or a workflow run that uses the action — and send a prompt. Open the Intake page in the Sazabi dashboard and confirm events from the Claude Code source appear within a minute or two. Start a thread and search for claude_code.api_request to find model API requests with token counts and cost, or search for session.id to view all events from a single session. To compare surfaces and repositories, group events by app.entrypoint or vcs.repository.name; cloud sessions also carry ccr.session.id, which identifies each cloud session.

Troubleshooting

No events after restarting — Confirm ~/.claude/settings.json is valid JSON and the env block is correctly nested. Claude Code silently ignores settings files that fail to parse. Events appear but prompts are missing — Confirm OTEL_LOG_USER_PROMPTS is enabled, then restart Claude Code. Prompt text is exported starting with the next session; a session that predates the setting will not include it. If privacy is a concern, set it to 0 — session structure and API metadata are still exported. No events from cloud sessions — Confirm the intake URL’s hostname is in Allowed domains for the environment the session ran in, and that the session started after you saved the managed settings. Each environment has its own allowlist. No events from GitHub Actions — Confirm the env block is on the anthropics/claude-code-action step itself and that the SAZABI_OTLP_ENDPOINT secret is set in the repository. Workflows triggered from forks do not receive repository secrets. Metric data points show up as log records — Sazabi stores each metric data point as a log record; it isn’t a metrics store. The setup above sends logs only; unset OTEL_METRICS_EXPORTER to stop sending metrics and keep volume down.

Further reading

Intake

See per-source ingestion volume and health.

Log sources

Browse the full log source catalog.