Skip to content

metrics: cut pre-created bucket and label products on the churn-heavy emitters - #23039

Merged
Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Git-on-my-level:metrics-emitter-cardinality-cuts
Oct 21, 2026
Merged

Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Git-on-my-level:metrics-emitter-cardinality-cuts

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Companion to the exporter-pin PR. The four churn-heaviest families pre-create their full label × bucket product at import, and every listen/pusher pod and Cloud Run instance replacement re-creates it (121 distinct listen pods and ~1,500 bridge instances per 6h on 2026-10-21, against 2.27M head series for ~200k live). This trims the products without changing metric names or label sets.

Changes

Metric Change Per-emitter series
omi_journey_latency_seconds 15 → 10 finite buckets (0.5 … 21600s); the 3×4 journey/outcome pre-create stays 192 → 132 (−31%)
omi_conversation_duration_seconds, omi_conversation_speech_seconds 18 → 11 finite buckets; keeps 10 and 15 (omi_conversation_shape contract log) and 120 (Core Features long-conversation share, le="120.0") 114 → 72 each (−37%)
omi_sync_phase_duration_seconds, omi_sync_phase_calls_per_job 10 → 7 and 10 → 6 finite buckets; keeps the le=0/le=1 pair that isolates zero-call attempts 130 → 100 per backend-sync instance (−23%), on both the custom-metric write and the GMP sidecar export
omi_fallback_total import-time zero baseline drops text/no_text (transcript-outcome tokens, never fallback reasons) ~984 → ~936 (−5%)

New tests/unit/test_metrics_cardinality_contract.py pins the four budgets and asserts the fallback baseline still covers the alert matrix while excluding the transcript tokens. test_conversation_shape.py (le=10/15/120), test_modulate_capacity_failover.py (zero-baseline contract), test_sync_phase_metrics.py, test_journey_observability.py and test_monitoring_telemetry_contract.py pass unchanged.

Why the fallback matrix mostly stays

increase() cannot observe a one-off burst on a lazily created counter: its first sample already holds the burst and the flat tail reads as 0. The retired-provider alert (component=~"stt_selection|stt_live_session", to_mode!="unavailable" by to_mode, 6h window), the capacity_full-by-to_mode alert and the chain-exhaustion ratio select across the whole from × to × reason product, so each of those series needs a zero baseline on every pod — the exact class test_exhausted_children_have_a_zero_baseline_before_the_first_burst guards. Shrinking it further means shrinking the reason vocabulary or moving that alert onto a pre-aggregated per-to_mode counter (follow-up; would remove ~540 of the ~984 per emitter).

Bucket boundaries checked

No alert, recording rule or dashboard reads an explicit le= on the journey or sync-phase histograms; the only explicit read anywhere is omi_conversation_duration_seconds_bucket{le="120.0"} (kept). All other consumers are histogram_quantile p10/p50/p90/p95 panels (Core Features, resilience-fallbacks, omi-core-selfheal doc, sync rightsizing runbook on GMP).

Before / after (prod, 2026-10-21)

Today, live → distinct series per 6h: journey 31.3k → 322k; conversation 18.6k → 191k; sync phase 13.6k → 136k. Estimated head after this PR: −190k (journey −100k, conversation −91k, fallback −7k). Together with the exporter-pin PR: ~1.7M vs 2.27M today.

Product invariants affected

None. Metric names and label sets are unchanged; only histogram bucket boundaries and the set of pre-created zero-valued omi_fallback_total series change.

Rollout

Touches listen (utils/metrics.py and utils/observability/fallback.py ship in the listen image, alongside pusher, llm-gateway, backend-api and backend-sync). Deploy off-peak (before 13:00Z or after 22:00Z), carried by the rollout lead. During the rolling restart, sum by (le) quantile panels mix old and new bucket sets for roughly one scrape window per pod and read slightly skewed; nothing is lost once the roll completes.

UI-Evidence: none -- metrics emitter change; no user-facing surface.
Failure-Class: FC-alert-never-provably-fired

View guided diff

… emitters

Prod in-cluster Prometheus held 2.27M head series on 2026-10-21 against
~200k live in the top families: every pod and Cloud Run instance
replacement re-creates each emitter's full pre-built product (121
distinct listen pods and ~1,500 bridge instances per 6h), so a bucket
or label is a standing head cost, not a one-time one. Names and label
sets are unchanged; only the products shrink.

- omi_journey_latency_seconds: 15 -> 10 finite buckets
  (0.5..21600s); 192 -> 132 series per emitter (-31%). The 3x4
  journey/outcome pre-create stays. Only p50/p95 quantile panels read
  this histogram; no rule reads an explicit le= boundary.
- CONVERSATION_DURATION_BUCKETS: 18 -> 11 finite buckets, keeping 10
  and 15 (omi_conversation_shape contract log) and 120 (Core Features
  long-conversation share, le="120.0"); 114 -> 72 series per emitter
  for duration and for speech seconds each (-37%).
- omi_sync_phase_duration_seconds 10 -> 7 and
  omi_sync_phase_calls_per_job 10 -> 6 finite buckets, keeping the
  le=0/le=1 pair that isolates zero-call attempts; 130 -> 100 series
  per backend-sync instance (-23%), on both the custom-metric write and
  the GMP sidecar export.
- omi_fallback_total: the import-time zero baseline drops the
  transcript-outcome tokens text/no_text (never fallback reasons): 48
  fewer series per emitter. The rest of the ~984-series matrix stays
  deliberately -- increase() cannot observe a one-off burst on a lazily
  created counter, and the retired-provider and capacity_full-by-to_mode
  alerts select across the whole from x to x reason product -- and the
  docstring now says so.

tests/unit/test_metrics_cardinality_contract.py pins the four budgets
and asserts the baseline still covers the alert matrix while excluding
the transcript tokens. Measured on prod before the change: journey
31.3k live -> 322k distinct series per 6h; conversation 18.6k -> 191k;
sync phase 13.6k -> 136k. Estimated head after: -190k (journey -100k,
conversation -91k) on top of the exporter pin PR.

Failure-Class: FC-alert-never-provably-fired
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-21T12:43:07.594426Z 42c12dc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 8a1de0d into BasedHardware:main Oct 21, 2026
52 checks passed
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.

1 participant