Skip to content

Observability for Claude Code & Anthropic Agents

Gain complete visibility into your Claude Code sessions and Anthropic-powered agentic workflows. The Anosys Platform captures every trace, metric, and log emitted by Claude Code via OpenTelemetry (OTLP), giving you the insights you need to optimize costs, debug failures, and ship faster.


Why Observability Matters for AI Agents

Agentic AI workflows are fundamentally different from traditional software — they are non-deterministic, multi-step, and often expensive to run. Without observability you are flying blind:

Challenge What Observability Gives You
Non-deterministic outputs Trace every reasoning step so you can reproduce and compare runs
Runaway token usage Real-time metrics on input/output tokens per session
Silent failures Structured logs with error classification and alerting
Slow iterations Latency breakdowns across tool calls and model invocations
Cost overruns Per-session and per-project cost attribution dashboards

Getting Started with Claude Code

Claude Code is Anthropic's agentic AI coding assistant that operates directly in your terminal. It reads your codebase, proposes edits, runs commands, and iterates — all powered by Claude.

To monitor your Claude Code sessions with Anosys, you only need to:

  1. Create a pixel in the Anosys Console of type "Agentic AI".
  2. Configure ~/.claude/settings.json with your OTLP endpoint (see below).
  3. Restart Claude Code — traces flow automatically.

No SDK to install. No code changes. Just configuration.


Setting Up Observability for Claude Code

Step 1 — Create Your Anosys Pixel

Log in to the Anosys Console and create a new pixel of type Agentic AI. Copy the OTLP endpoint URL shown on the pixel configuration page — you'll need it in the next step.

Step 2 — Configure Claude Code

Create or edit (if it exists) the ~/.claude/settings.json file in your Claude Code installation and add the following configuration:

{
    "env": {
        "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
        "OTEL_SERVICE_NAME": "claude-code",
        "OTEL_TRACES_EXPORTER": "otlp",
        "OTEL_METRICS_EXPORTER": "otlp",
        "OTEL_LOGS_EXPORTER": "otlp",
        "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
        "OTEL_EXPORTER_OTLP_ENDPOINT": "YOUR_ANOSYS_OTLP_ENDPOINT"
    }
}

Replace YOUR_ANOSYS_OTLP_ENDPOINT with the OTLP endpoint URL from your Anosys Console pixel.

Custom service name

You can change the OTEL_SERVICE_NAME value to any label you prefer (e.g. claude-code-backend, my-team-agent). This name is used to group and filter traces in the Anosys dashboards.

Step 3 — Restart Claude Code

After saving settings.json, restart Claude Code. Telemetry will begin flowing immediately.


What You'll See in Anosys

Once telemetry is active, the Anosys Platform automatically processes your Claude Code data and surfaces:

  • Session traces — End-to-end visibility into every Claude Code session, including tool calls, file reads/writes, and command executions.
  • Token usage metrics — Input and output token counts per session, per project, and over time.
  • Latency analysis — Identify slow model calls and bottlenecks across your agent's workflow.
  • Error tracking — Structured error logs with automatic classification to help you root-cause failures fast.
  • Cost insights — Per-session cost estimates to keep your AI spend under control.
  • Anomaly detection — ML-powered baselines that alert on unusual session lengths, token spikes, and unexpected error patterns without manual threshold configuration.
  • Root cause analysis — Causal graphs that connect failures to upstream triggers — trace a broken build back through file edits, command executions, and model decisions.
  • Alerts — Context-aware notifications via Slack, email, PagerDuty, or webhooks when Claude Code sessions hit errors, cost overruns, or performance regressions.
  • Custom dashboards — Build your own views or start with auto-generated dashboards for session health, cost trends, and project-level usage.
  • Automated metric generation — Anosys automatically generates key metrics from your traces and logs so you get dashboards in minutes, not days.
  • Custom pipelines — Enrich, route, and transform your Claude Code telemetry with automated remediation workflows.
  • Labeling — Tag and annotate sessions, projects, or teams with custom labels for segmentation and drill-down analysis.
  • Natural language interface — Ask questions about your Claude Code sessions in plain English and get answers backed by your telemetry.

Configuration Reference

Below is a summary of the environment variables used in settings.json:

Variable Description
CLAUDE_CODE_ENABLE_TELEMETRY Set to 1 to enable telemetry export
OTEL_SERVICE_NAME Logical name for your service in traces and dashboards
OTEL_TRACES_EXPORTER Exporter type for traces (use otlp)
OTEL_METRICS_EXPORTER Exporter type for metrics (use otlp)
OTEL_LOGS_EXPORTER Exporter type for logs (use otlp)
OTEL_EXPORTER_OTLP_PROTOCOL Transport protocol (use http/protobuf)
OTEL_EXPORTER_OTLP_ENDPOINT Your Anosys OTLP ingestion endpoint URL

Troubleshooting

I don't see any data in the Anosys Console
  • Verify that ~/.claude/settings.json is valid JSON (no trailing commas).
  • Confirm that CLAUDE_CODE_ENABLE_TELEMETRY is set to "1" (string, not integer).
  • Double-check that your OTEL_EXPORTER_OTLP_ENDPOINT matches the URL shown in your Anosys pixel.
  • Make sure you restarted Claude Code after saving the file.
Can I use this alongside other OTLP collectors?

Yes. You can point OTEL_EXPORTER_OTLP_ENDPOINT at any OTLP-compatible collector or gateway. If you need to fan out to multiple backends, place an OpenTelemetry Collector in between and configure multiple exporters there.

Does this work with Claude Code on remote servers or containers?

Yes — as long as ~/.claude/settings.json is present in the home directory of the user running Claude Code, telemetry will be exported regardless of environment.


Next Steps