Repository navigation
fix(prometheus): prevent worker metrics from starving core families - #180117
Merged
steipete merged 2 commits intoOct 22, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 22, 2026 01:22
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
force-pushed
the
steipete/perf-micro-metric-family-budgets-20261022
branch
from
October 22, 2026 01:29
6aa4517 to
af8e37d
Compare
steipete
deleted the
steipete/perf-micro-metric-family-budgets-20261022
branch
October 22, 2026 01:38
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 22, 2026
…penclaw#180117) * fix(prometheus): prevent worker metrics from starving core families * test(prometheus): include timestamps in saturation phase events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes missing run, model, tool, GC, and memory metrics when worker/RPC startup traffic consumes the Prometheus exporter's shared series cap. Follow-up to #180103, which protected only the four native main-GC histograms.
User Impact
Late metric families retain reserved capacity, and operators can identify partial coverage through
openclaw_prometheus_family_series_dropped_total{family="..."}plus one warning per family per process. Existingopenclaw_prometheus_series_dropped_totalremains available.The aggregate-entry limit stays 2,048. A busy family now stops admitting new label sets at 128, or when shared capacity fills. Existing samples keep updating. No labels or histogram buckets are rewritten; high-cardinality coverage can be partial and the drop counter identifies the affected family.
Why This Change Was Made
The old first-come cap counted stored
{metric, labels}aggregates, not rendered bucket rows. More worker telemetry (including #179872) could consume capacity before runs completed. Clearing and rebuilding memory gauges also exposed their slots to other families. Reducing histogram buckets alone would not repair admission.The metric store now owns a typed catalog of 134 families with 1,204 reserved entries and 844 shared entries, plus the 128-entry family ceiling. Core run/model/tool/GC families reserve 32 entries; memory reserves cover bounded thread/slot/heap-space layouts; other families reserve four. The catalog records every exact reserve and requires new producers to choose one. Unused reservations remain available for future families. Main-GC startup reservation remains within its family budget.
Drop accounting bypasses admission and uses only cataloged family names. It counts rejected observations, including repeated attempts at a rejected label set. Gauge replacement releases the correct family/shared accounting. Exporter reset clears metrics and counts while preserving process-wide warning suppression.
Production code grows by 201 lines, chiefly the explicit family catalog and admission/drop accounting required for this observability contract. This replaces the shared first-come admission policy; it adds no configuration or second admission path. The existing benchmark fixture is updated to fill all reserves before shared capacity so its retained-size workload still means 2,048 entries.
Evidence
A synthetic exporter regression sends 400 worker request classes and 426 RPC methods before late core events and repeated memory snapshots. On the unchanged store from
cc4ca8d1, the core-family assertion fails. With this change, it passes:Across that identical synthetic sequence: 7 → 45 application metric families, 2,048 → 1,066 retained aggregates, and 38,877 → 21,719 rendered series, including drop diagnostics. The remaining capacity protects families not yet observed. Worker GC's repeated cumulative sample stays at 7 collections, not 14.
Focused exporter tests: 46 passed, including the saturated exporter, all-family 2,048-entry bound, gauge replacement, reset, worker GC totals, and once-per-process warnings. Targeted plugin typecheck passed. Changed-file lint/format, the export-name guard, and both closure guards (22 tests) passed. The final subscription file also passed all 9 tests after fixture typing cleanup. Independent Codex review is clean through P2. Initial CI caught two missing required
startedAtfields in the new synthetic phase-event fixtures. Those two fixture fields are corrected; the focused file (9 tests), lint, and independent review passed again. Production code and the measured counts are unchanged. Exact-head PR CI supplies the broad gates.This is deterministic exporter/HTTP-handler proof with synthetic events, not a production scrape or a full Gateway boot. No production process, state, or configuration was changed. There is no wall-time, allocation, or memory-byte performance claim, and the cap was not increased.