Skip to content

fix(metrics): remove watchable_depth, which always reported 0 - #9860

Open
somaz94 wants to merge 5 commits into
envoyproxy:mainfrom
somaz94:fix/watchable-depth-metric
Open

somaz94 wants to merge 5 commits into
envoyproxy:mainfrom
somaz94:fix/watchable-depth-metric

Conversation

@somaz94

@somaz94 somaz94 commented Aug 27, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

watchable_depth recorded len(subscription), where subscription is the channel
returned by watchable.Map.Subscribe(). That channel is unbuffered
(downstream := make(chan Snapshot[K, V]) in the watchable library), so the gauge
could only ever read 0, while the shipped Grafana dashboard graphed it as queue depth.

An earlier revision of this PR repurposed the gauge as len(snapshot.Updates). As
discussed in review, that is the size of one batch rather than a backlog, and because
it returns to 0 once the batch is handled, whether a scrape sees it depends on timing.
So this PR now removes the metric as a breaking cleanup instead.

Removing it touches more than the metric definition. Both envoy-gateway-global.json
and global-ratelimit.json build their Namespace and Runner template variables
from label_values(watchable_depth, ...), so dropping the metric on its own would leave
those selectors empty and blank every panel that filters on them. They now read from
watchable_subscribe_total, which carries the same runner label and is recorded for
every handled snapshot. The Depth stat panel is removed and the Statistics panel moves
into its slot.

Batch-size histograms and a queue-wait metric are left for a follow-up, so this PR
stays a cleanup.

Validation was run locally on darwin/arm64 with the go.mod-pinned Go. make lint and
make gen-check both pass and leave the tree clean, and go test ./internal/message/... ./internal/metrics/... passes. make helm-template regenerates
test/helm/gateway-addons-helm/*.out.yaml, and the only change in them is the dashboard
edit above.

Which issue(s) this PR fixes:

Fixes #9776

Item 2 of that issue (subscribe-duration bucket spacing) already landed in #9812;
this is item 1.


PR Checklist

  • Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this PR. I have not submitted generated output I do not understand.
  • DCO: All commits are signed off (git commit -s).
  • API agreed first: N/A: no changes under /api.
  • Required checks pass: make lint and make gen-check pass locally, and the unit tests for the touched packages pass.
  • Tests added/updated: the earlier gauge test is removed along with the metric; the regenerated helm golden files cover the dashboard change.
  • Docs: removed the watchable_depth row from site/content/en/latest/tasks/observability/gateway-exported-metrics.md.
  • Release notes: release-notes/current/breaking_changes/9776-remove-watchable-depth.md.
  • Generated files committed: make gen-check is clean.
  • Scope & compatibility: one metric, the two dashboards that referenced it, its doc row and its release note. The removal is called out in release-notes/current/breaking_changes/.
  • Codex review: a Codex review ran on an earlier revision and found no issues; it has not run on the removal.
  • Copilot review: I can't request it as an external contributor, and it doesn't appear to be set up here.

@netlify

netlify Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit b4ae03a
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6ab2333249dff0000812d8f7
😎 Deploy Preview https://deploy-preview-9860--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f90d808a0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread internal/message/watchutil.go Outdated
@arkodg
arkodg requested review from zhaohuabing and zirain September 7, 2026 05:19
@somaz94
somaz94 force-pushed the fix/watchable-depth-metric branch from 0f90d80 to 418df1f Compare September 10, 2026 02:43
@zirain

zirain commented Sep 11, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 418df1fbe3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov

codecov Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.32%. Comparing base (76eb95f) to head (6a955cb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9860      +/-   ##
==========================================
- Coverage   81.32%   81.32%   -0.01%     
==========================================
  Files         264      264              
  Lines       41002    41003       +1     
==========================================
  Hits        33345    33345              
- Misses       7656     7657       +1     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

zirain
zirain previously approved these changes Sep 11, 2026
@somaz94

somaz94 commented Sep 15, 2026

Copy link
Copy Markdown
Author

/retest

@somaz94

somaz94 commented Sep 22, 2026

Copy link
Copy Markdown
Author

Thanks for the approval. The only red check is docs-lint, and it failed on a 408 timeout while crawling latest/tasks/security/index.xml, a page this PR does not touch. The same workflow has been green on main since then, so it looks like a flaky link check. Could you rerun the failed job when you get a chance?

Comment thread internal/message/metrics.go Outdated
watchableDepth = metrics.NewGauge(
"watchable_depth",
"Current depth of watchable queue.",
"Number of updates coalesced into the snapshot being handled, or 0 when idle.",

@zhaohuabing zhaohuabing Sep 22, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we probably should avoid changing the meaning of watchable_depth here.

len(snapshot.Updates) can still be useful, but it tells us how many updates arrived together in one batch—not how many updates are currently waiting to be processed.

If we expose it as a gauge, Prometheus might scrape after the batch has finished and the value has been reset to zero. That means it can miss a large batch even though the subscriber was temporarily falling behind.

Since the existing metric is permanently zero, I'd suggest removing watchable_depth (and its dashboard/documentation entry) as a breaking cleanup rather than repurposing it.

A follow-up can add an explicitly named histogram/counter for snapshot update counts, potentially both raw(watchable_snapshot_updates) and post-coalescing(watchable_coalesced_updates) counts, if that signal is valuable. For detecting control-plane lag, a queue-wait metric like watchable_queue_wait_seconds would be a more direct measure.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, that makes sense. Resetting to zero after each batch means what a scrape sees depends on timing, so it can miss exactly the bursts it is meant to show. I've turned this into a removal instead. One thing had to move with it: both envoy-gateway-global.json and global-ratelimit.json build their Namespace and Runner template variables from label_values(watchable_depth, ...), so removing the metric on its own would leave those selectors empty and blank every panel that filters on them. They now read from watchable_subscribe_total, which carries the same runner label, the depth panel is gone, and the helm golden files are regenerated. I've left the batch size histograms and a queue wait metric for a follow-up so this PR stays a cleanup.

…used it

Signed-off-by: somaz <genius5711@gmail.com>
… fix/watchable-depth-metric

Signed-off-by: somaz <genius5711@gmail.com>
@somaz94 somaz94 changed the title fix(metrics): record watchable_depth as the coalesced update count fix(metrics): remove watchable_depth, which always reported 0 Sep 22, 2026
@zhaohuabing zhaohuabing added this to the v1.10.0-rc.1 Release milestone Sep 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve the watchable control-plane metrics: watchable_depth is always 0, and subscribe duration buckets are too coarse below 10s

3 participants