Skip to content

atecontroller: add a zero-count bucket to empty exponential histograms - #1933

Merged
Jeff Luo (JeffLuoo) merged 5 commits into
agent-substrate:mainfrom
ericcurtin:atecontroller-drop-empty-workqueue-histograms
Oct 1, 2026
Merged

Jeff Luo (JeffLuoo) merged 5 commits into
agent-substrate:mainfrom
ericcurtin:atecontroller-drop-empty-workqueue-histograms

Conversation

@ericcurtin

@ericcurtin Eric Curtin (ericcurtin) commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1472.

The Telemetry API rejects an exponential histogram point with no positive buckets. Give such points one zero-count bucket instead.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

An idle workqueue bridges as an exponential histogram with no
positive buckets. Google Cloud Monitoring rejects that with
num_finite_buckets < 1 and drops it every push tick.

Filter those data points out before the OTLP push. No data is
lost, an idle queue has nothing to report anyway.

Fixes agent-substrate#1472.

Signed-off-by: Eric Curtin <[email protected]>

@JeffLuoo Jeff Luo (JeffLuoo) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on it, left some comments. Only Google Telemetry API with native OTLP exporter from OTel collector has the issue. I propose a way that will not impact other backends that natively accept OTLP data.

Comment thread cmd/atecontroller/metrics.go Outdated
//
// controller-runtime's workqueue metrics use native (exponential) Prometheus
// histograms, and the bridge produces one the moment a queue is created, before
// any item is ever processed. Google Cloud Monitoring rejects a data point in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only applies to Google Telemetry API (telemetry.googleapis.com).

Suggested text: "The Telemetry API (the Cloud Monitoring OTLP endpoint) rejects a data point in that state ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded to name the Telemetry API.

Comment thread cmd/atecontroller/metrics.go Outdated
Comment on lines +71 to +72
if len(dp.PositiveBucket.Counts) == 0 {
continue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A dropped point changes the data for every backend, but only one backend (Google Telemetry API) has the problem.

I tested an alternative on a GKE cluster with Managed OTel enabled. Instead of a drop, give the point one positive bucket with a count of 0:

 if len(dp.PositiveBucket.Counts) == 0 {
     dp.PositiveBucket = metricdata.ExponentialBucket{Counts: []uint64{0}}
 }

This would also work, meanwhile doesn't change the behaviour of metrics in other backends.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, switched to the zero-count bucket. Thanks for testing it on GKE.

Only the Telemetry API rejects them. Keep the point for other backends.
@ericcurtin Eric Curtin (ericcurtin) changed the title atecontroller: drop empty exponential workqueue histograms atecontroller: pad empty exponential workqueue histograms Sep 29, 2026
@mayawang Maya Wang (mayawang) added the kind/bug Something isn't working / bugfixes label Sep 29, 2026
@ericcurtin

Copy link
Copy Markdown
Contributor Author

Jeff Luo (@JeffLuoo) Now pads with a zero-count bucket as you suggested. PTAL when you get a chance. Thank you!

@JeffLuoo Jeff Luo (JeffLuoo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change the PR title to "atecontroller: add a zero-count bucket to empty exponential histograms"

Comment thread cmd/atecontroller/metrics_test.go Outdated
func TestPadEmptyExponentialHistogramsIdleWorkqueue(t *testing.T) {
t.Parallel()

q := workqueue.NewNamed("atecontroller-metrics-pad-probe")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, now uses NewWithConfig. Title updated too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks. NewWithConfig is deprecated too, now NewTypedWithConfig (fixes lint).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for fixing it!

@ericcurtin Eric Curtin (ericcurtin) changed the title atecontroller: pad empty exponential workqueue histograms atecontroller: add a zero-count bucket to empty exponential histograms Sep 30, 2026
@ericcurtin

Copy link
Copy Markdown
Contributor Author

Jeff Luo (@JeffLuoo) PTAL when you get a chance. Thank you!

@JeffLuoo
Jeff Luo (JeffLuoo) added this pull request to the merge queue Oct 1, 2026
Merged via the queue into agent-substrate:main with commit b5ad4b3 Oct 1, 2026
10 checks passed
@ericcurtin
Eric Curtin (ericcurtin) deleted the atecontroller-drop-empty-workqueue-histograms branch October 2, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Google Cloud Monitoring drops workqueue exponential histograms with INVALID_ARGUMENT (num_finite_buckets = 0)

5 participants