# Practical ways to use the Claude Agent SDK
📊 Visualize all agent activity in Datadog, Grafana, or Langfuse with OpenTelemetry.
OpenTelemetry Observability exports agent traces, metrics, and logs via OTLP to external monitoring tools.
📌 Title: Observability with OpenTelemetry
🔗 URL:
🧩 Overview
Enable with `CLAUDE_CODE_ENABLE_TELEMETRY=1` to export traces, metrics, and logs via OTLP to Honeycomb, Datadog, Grafana, Langfuse, and more. W3C trace context propagation automatically links agent traces to your application traces.
🛠 How to use it
```bash
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1
export OTEL_EXPORTER_OTLP_ENDPOINT=https://your-collector:4318
```
🏗 Practical usage
- Monitor "which tools were called, how long each took, how many tokens were used, and where failures occurred" in a single Datadog dashboard.
- Get `claude_code.interaction` / `llm_request` / `tool` / `hook` spans with enhanced telemetry to visualize entire sub-agent delegation chains in one trace.
- Inject ` / ` via `OTEL_RESOURCE_ATTRIBUTES` to build per-user audit trails and forward to SIEM.
💡 Use cases
🔍 Detailed trace analysis of agent execution
👥 Per-user audit trails
🚨 Bottleneck identification during failures
⚠️ Watch out
The `console` exporter conflicts with the SDK's message channel — don't use it. For short-lived processes, shorten `OTEL_*_EXPORT_INTERVAL` to prevent missed flushes.
#
ClaudeAgentSDK# #
AI#