claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Error: Unknown protocol set in OTEL_EXPORTER_OTLP_METRICS_PROTOCOL

Open channingwalton opened this issue 8 months ago • 8 comments

Environment

  • Platform (select one):
    • [x] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: ?
  • Operating System: macOs 10.15.5
  • Terminal: ghostty
  • Node.js v23.11.0

Bug Description

After using Claude today it said that was an upgrade so I quit and restarted Claude, but it fails with:

Error: Unknown protocol set in OTEL_EXPORTER_OTLP_METRICS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: undefined
    at jT5 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1453:6529)
    at xT5 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1453:7131)
    at file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1453:7874

Steps to Reproduce

  1. Upgrade claude
  2. run claude

Expected Behaviour

No crash

Actual Behavior

crash

Additional Context

I tried deleting and reinstalling but got the same issue.

channingwalton avatar May 21 '25 13:05 channingwalton

@channingwalton are you trying to use any of the open telemetry features as documented here?

Specifically do you have the following env vars set: CLAUDE_CODE_ENABLE_TELEMETRY=1 and OTEL_EXPORTER_OTLP_METRICS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL

sid374 avatar May 21 '25 20:05 sid374

@channingwalton are you trying to use any of the open telemetry features as documented here?

No, I ran claude successfully, it said there was an update and to restart, so I did, and the result was this bug.

channingwalton avatar May 21 '25 20:05 channingwalton

Sorry I do have the following set

  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp"
  }

Deleting that has resolved the problem.

But as I say it did work prior to the upgrade.

channingwalton avatar May 21 '25 20:05 channingwalton

BTW, that doc link seems to be an internal anthropic url

channingwalton avatar May 21 '25 20:05 channingwalton

Thanks, fixed the link. Glad you are unblocked now, and we'll look into a possible regression.

Also curious what your use case for setting up OTEL was?

sid374 avatar May 21 '25 20:05 sid374

Also curious what your use case for setting up OTEL was?

I really don't recall doing it, I must have copied it from somewhere blindly.

channingwalton avatar May 21 '25 21:05 channingwalton

Found it, I copied it from the settings docs.

channingwalton avatar May 21 '25 21:05 channingwalton

I hit this problem Today, after claude updated to 1.0.31; Nothing was changed in my development environment.

I have to follow these steps to make it work again:

You can make your OpenTelemetry configuration permanent by adding it to your Claude Code settings file. Here's how: Add the environment variables to your user settings file at ~/.claude/settings.json:

{
  "env": {
    "CLAUDE_CODE_ENABLE_TELEMETRY": "1",
    "OTEL_METRICS_EXPORTER": "otlp",
    "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc",
    "OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317"
  }
}

This will apply these settings every time you run Claude Code.
For project-specific settings, you can add them to .claude/settings.json in your project directory.
If you're an administrator configuring for multiple users, you can set these in the managed settings file:
macOS: /Library/Application Support/ClaudeCode/managed-settings.json
Linux: /etc/claude-code/managed-settings.json

Source: https://docs.anthropic.com/en/docs/claude-code/monitoring-usage

diegonix avatar Jun 21 '25 18:06 diegonix

This issue seems resolved. Closing this - feel free to reopen if you encounter this again

kushal-thakkar avatar Jun 27 '25 19:06 kushal-thakkar

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 05 '25 14:08 github-actions[bot]