gemini-cli - 💡(How to fix) Fix bug: OpenTelemetry metrics export fails when `routing_reasoning` label exceeds 1024 characters [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error log: Error: PeriodicExportingMetricReader: metrics export failed (error Error: Send TimeSeries failed...)

Root Cause

This happens because the internal OpenTelemetry/MetricReader attempts to send telemetry data to Google Cloud, but the routing_reasoning metric label generated by the model routing classifier exceeds the strict maximum string size of 1024 characters allowed by the Google Cloud Monitoring API.

Fix Action

Fixed

Code Example

gemini-cli -p "Your long prompt/transcript here..." --output-format json

### What did you expect to happen?

Expected behavior
The telemetry/metrics export should gracefully truncate any label values (like routing_reasoning) to 1024 characters before attempting to write the TimeSeries.

The CLI should output a clean JSON object without polluting stdout or stderr with internal telemetry crashes.

### Client information

<details>
<summary>Client Information</summary>

Run `gemini` to enter the interactive CLI, then run the `/about` command.

---

</details>

### Login information

Google Account

### Anything else we need to know?

Error log:
RAW_BUFFERClick to expand / collapse

What happened?

Describe the bug

When running gemini-cli with a prompt using the -p flag and requesting a JSON output format, the execution throws multiple massive Node.js stack traces and Google Cloud Monitoring errors.

This happens because the internal OpenTelemetry/MetricReader attempts to send telemetry data to Google Cloud, but the routing_reasoning metric label generated by the model routing classifier exceeds the strict maximum string size of 1024 characters allowed by the Google Cloud Monitoring API.

To Reproduce

Run a prompt that involves processing a large context (e.g., a long meeting transcript) and outputs a detailed internal routing reasoning:

gemini-cli -p "Your long prompt/transcript here..." --output-format json

### What did you expect to happen?

Expected behavior
The telemetry/metrics export should gracefully truncate any label values (like routing_reasoning) to 1024 characters before attempting to write the TimeSeries.

The CLI should output a clean JSON object without polluting stdout or stderr with internal telemetry crashes.

### Client information

<details>
<summary>Client Information</summary>

Run `gemini` to enter the interactive CLI, then run the `/about` command.

```console
> /about
 About Gemini CLI                                                                                                                                                                                                                                        │
│                                                                                                                                                                                                                                                         │
│ CLI Version                                                                           0.45.0                                                                                                                                                            │
│ Git Commit                                                                            0a11ce3e9                                                                                                                                                         │
│ Model                                                                                 Auto                                                                                                                                                              │
│ Sandbox                                                                               no sandbox                                                                                                                                                        │
│ OS                                                                                    darwin                                                                                                                                                            │
│ Auth Method                                                                           Signed in with Google (xxx)│ Tier                                                                                  Gemini Code Assist Standard                                                                                                                                       │
│ GCP Project                                                                           xxx
</details>

Login information

Google Account

Anything else we need to know?

Error log:

Send TimeSeries failed: One or more TimeSeries could not be written: timeSeries[8] (metric.type="[custom.googleapis.com/gemini_cli/gemini_cli.model_routing.latency](https://custom.googleapis.com/gemini_cli/gemini_cli.model_routing.latency)"...
Field metric.labels had an invalid value of "routing_reasoning": Label value exceeds the maximum string size of 1024 characters.

Error: PeriodicExportingMetricReader: metrics export failed (error Error: Send TimeSeries failed...)
    at PeriodicExportingMetricReader2._doRun (file:///opt/homebrew/Cellar/gemini-cli/0.45.0/libexec/lib/node_modules/@google/gemini-cli/bundle/chunk-6T7N6JF2.js:72518:17)

Environment:

  • OS: macOS (Homebrew installation)
  • Gemini CLI Version: 0.45.0
  • Node.js Environment: internal process task queues (as bundled in the CLI)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING