Skip to content

How to send Claude Code telemetry to Dynatrace (OTLP) — 3 steps #2

Description

@neeltom92

Send Claude Code telemetry to Dynatrace (OTLP) — 3 steps

Claude Code already speaks OTLP. To get its metrics + logs/events into Dynatrace,
you just point an OpenTelemetry Collector at Dynatrace's native OTLP endpoint.
Local Prometheus/Loki/Grafana stay untouched — Dynatrace is an additional exporter.

Step 1 — Run the OTEL Collector

Use the collector from this repo (make up), or any OTel Collector. Claude Code
sends OTLP/HTTP to it at http://127.0.0.1:4318.

Step 2 — Patch Claude Code settings (telemetry on)

make patch (or set these in ~/.claude/settings.jsonenv):

{
  "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
  "OTEL_METRICS_EXPORTER": "otlp",
  "OTEL_LOGS_EXPORTER": "otlp",
  "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
  "OTEL_EXPORTER_OTLP_ENDPOINT": "http://127.0.0.1:4318",
  "OTEL_METRICS_ENABLED": "true",
  "OTEL_LOG_TOOL_DETAILS": "1"
}

Restart Claude Code so the env vars take effect.

Step 3 — Point the Collector's exporter at Dynatrace OTLP

Add a Dynatrace exporter and wire it into the metrics + logs pipelines:

exporters:
  otlphttp/dynatrace:
    endpoint: "${env:DT_ENDPOINT}"        # https://{env-id}.live.dynatrace.com/api/v2/otlp
    headers:
      Authorization: "Api-Token ${env:DT_API_TOKEN}"

processors:
  cumulativetodelta: {}   # Dynatrace wants delta temporality; OTEL emits cumulative

service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [cumulativetodelta]
      exporters: [otlphttp/dynatrace]
    logs:
      receivers: [otlp]
      exporters: [otlphttp/dynatrace]

otlphttp auto-appends /v1/metrics and /v1/logs.

Token requirements (important)

  • Use a classic Access token (dt0c01...) with scopes metrics.ingest +
    logs.ingest.
  • Platform tokens (dt0s16...) do NOT work for OTLP ingest — metrics return
    401 unsupported authorization scheme.

Verify

curl -s -o /dev/null -w "%{http_code}\n" -X POST "$DT_ENDPOINT/v1/metrics" \
  -H "Authorization: Api-Token $DT_API_TOKEN" -H "Content-Type: application/x-protobuf" --data ''
# 200 = OK. 401 = wrong token type/scheme. 403 = missing scope.

Then in Dynatrace: Metrics → search claude_code.*; Logs
fetch logs | filter service.name == "claude-code".

This repo ships an opt-in implementation: make up-dynatrace + dynatrace/ configs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions