[BUG] - AggregationTemporality Missing On OTEL Metrics

Resolved 💬 4 comments Opened Jul 11, 2025 by cpsnowden Closed Jul 29, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.48 (Claude Code)
  • Operating System: MacOSX 15.5
  • Terminal: Terminal App

Bug Description

OTEL metrics rejected by Grafana Cloud due to missing AggregationTemporality

Grafana collection error

ts=2025-07-11T19:19:38.922459868Z caller=otel.go:157 level=error user=2555203 msg="detected an error while ingesting OTLP metrics request (the request may have been partially ingested)" httpCode=400 err="rpc error: code = Code(400) desc = otlp parse error: invalid temporality and type combination for metric \"claude_code.session.total\"" insight=true

Example console out of metric

{
  descriptor: {
    name: 'claude_code.session.count',
    type: 'COUNTER',
    description: 'Count of CLI sessions started',
    unit: '',
    valueType: 1,
    advice: {}
  },
  dataPointType: 3,
  dataPoints: [
    {
      attributes: {
        'user.id': '74ba1eb7e700cb302413d412fa893f3e4776e9226bc639bf3748954780c01a66',
        'session.id': '35cf0cec-229a-4bfd-9976-021ae7483dfc',
        'organization.id': 'd3814445-8126-480c-b168-d54b2a31a9fd',
        'user.email': 'chris.snowden@accurx.com',
        'user.account_uuid': 'a39ebdff-3873-47a2-919e-32a95d105032',
        'terminal.type': 'Apple_Terminal'
      },
      startTime: [ 1752263363, 656000000 ],
      endTime: [ 1752263668, 628000000 ],
      value: 1
    }
  ]
}

Steps to Reproduce

  1. Configuration
{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "CLAUDE_CODE_DEBUG": "1",
    "OTEL_METRICS_EXPORTER": "console,otlp",
    "OTEL_LOGS_EXPORTER": "otlp",
    "OTEL_TRACES_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "https://otlp-gateway-prod-gb-south-1.grafana.net/otlp",
    "OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Basic ....",
    "OTEL_METRIC_EXPORT_INTERVAL": "500",
    "OTEL_LOGS_EXPORT_INTERVAL": "500",
    "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": "cumulative"
  }
}
  1. Console reporter indicates that AggregationTemporality is not being set

Expected Behavior

AggregationTemporality can be set e.g. using OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE

Actual Behavior

Field not set resulting in metric being rejected

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗