Connect Claude Code

Claude Code is Anthropic’s agentic coding CLI. It ships with a built-in OpenTelemetry logs exporter that emits an api_request log for every model call it makes. Pointing that exporter at Dobby gives you out-of-band monitoring of the CLI’s own routing — the model name, token usage, and cost per turn — with no gateway and nothing in the request path.

What this monitors. This connector observes Claude Code’s own model calls (its per-turn routing), not the agents you build with the Dobby SDK. It’s the fastest way to bring the CLI itself under governance — set a few env vars and run claude as you normally would.

Prerequisites

  • Claude Code installed and working (claude --version).
  • A Dobby connector for this tenant — created from Workloads → Connect a Workflow → Claude Code. Copy the generated ingest token + webhook URL (shown once).

Quickstart

  1. In Dobby, go to Workloads → Connect a Workflow → Claude Code. Name the connector and copy the minted ingest token + webhook URL.
  2. Export the environment variables below in the shell where you run Claude Code, using the http/json protocol.
  3. Run claude. Each turn’s model call streams to Dobby and auto-scans against your activated frameworks.
# Launch Claude Code with telemetry pointed at your Dobby connector.
# Set these in your shell before running `claude`. Claude Code has a built-in
# OpenTelemetry logs exporter — no plugin to install.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=none
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json

# Point the exporter at your Dobby connector webhook. The generic endpoint
# auto-appends /v1/logs — the connector accepts that path. (The per-signal
# OTEL_EXPORTER_OTLP_LOGS_ENDPOINT also works: same URL, used verbatim.)
export OTEL_EXPORTER_OTLP_ENDPOINT=https://dobby-ai.com/api/v1/webhooks/workloads/<connectorId>
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <your-ingest-token>"

# Run your agents. Every model call streams to Dobby and auto-scans on arrival.
# Verify in Workloads → Runs within a few seconds.
Endpoint forms. The snippet uses the generic OTEL_EXPORTER_OTLP_ENDPOINT, which auto-appends /v1/logs — the connector accepts that path. The per-signal OTEL_EXPORTER_OTLP_LOGS_ENDPOINT also works: set it to the exact connector URL (used verbatim, no suffix).

How runs appear

Dobby ingests each api_request OTLP log and captures the per-turn routing:

  • Model — which Claude model served the turn.
  • Token usage — input / output tokens per turn.
  • Cost — the per-turn cost the CLI reports.

Runs finalize via an idle-sweep — a short delay after the turn goes quiet — then land in your tenant’s Workloads → Runs feed and auto-scan against your activated frameworks.

Content capture (optional)

By default this connector is routing-only — it stores the model, tokens, and cost per turn, but not your prompt text. If your evidence needs the prompt content, you can opt in per connector:

  1. Enable “Also capture prompt content” when you create the connector (or PATCH capture_content: true on an existing one).
  2. Additionally launch Claude Code with OTEL_LOG_USER_PROMPTS=1. Claude Code redacts prompt text from its telemetry by default, so without this flag nothing is captured — the connect wizard adds this line to your snippet automatically when the toggle is on.
Before you enable it. Secrets (API keys, tokens) are masked server-side, but content capture stores the rest of your prompt as-is — including proprietary code and any PII such as emails or IPs. Leave it off unless you specifically need prompt text as evidence.

Notes & limits

  • Protocol: v1 accepts OTLP/HTTP JSON (OTEL_EXPORTER_OTLP_PROTOCOL=http/json), gzip-compressed or plain. Exporters sending protobuf receive an HTTP 400 asking to switch the encoding to json.
  • Redaction: secrets (keys, tokens) are masked server-side on ingest before the run is stored. This is secrets-only, not full PII — see Content capture above.
  • Auth: the bearer token you set in OTEL_EXPORTER_OTLP_HEADERS is validated against the connector’s stored secret on every delivery.
Instrumenting an agent you built instead of the CLI? See the Dobby Collector SDK quickstart.
Connect Claude Code | Dobby Docs