Skip to content

fix(metrics): name the relevance counter so the Cloud Run sidecar keeps it - #17280

Merged
Git-on-my-level merged 2 commits into
mainfrom
fix/relevance-metric-prefix
Sep 23, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
fix/relevance-metric-prefix

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Why

The relevance counter shipped in #16587 (conversation_relevance_decision_total) never reaches Prometheus: the Cloud Run managed-Prometheus sidecar (backend/deploy/cloud_run_gmp_sidecar.yaml) keeps only omi_.* names, so the metric is exported on /metrics and dropped at ingestion. Found during the post-deploy watch of a8975fa68a: omi_product_event_total is present in Prometheus from the same process, while the relevance counter has no series.

What

  • Rename to omi_conversation_relevance_decision_total.
  • test_relevance_metric_is_scraped.py reads the sidecar keep regex from the deploy YAML and asserts the counter name matches it.

lazy_desktop_deferral_total and jit_first_open_total in the same module are dropped the same way; not changed here (their dashboards/alerts are someone else's to rename).

Failure-Class: new

Failure-class transition narrative

Adds FC-metric-dropped-by-scrape-allowlist. Violated contract: a metric a feature relies on for visibility must survive the collector's keep rule; a non-omi_ Cloud Run metric passes every test and is dropped at ingestion, so "no data" looks like "nothing happened". Canonical guard: omi_ prefix plus a unit test that reads the sidecar keep regex from the deploy YAML. Evidence: conversation_relevance_decision_total absent from Prometheus after the 2026-09-23 prod deploy while omi_product_event_total from the same process is present.

Verification

  • New test passes; fails against the old name.
  • Not measured: the series in Prometheus (after deploy).

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 2 commits September 23, 2026 15:37
…ps it

The Cloud Run managed-Prometheus sidecar keeps only omi_.* metric names, so
conversation_relevance_decision_total was exported but dropped at ingestion
after the #16587 deploy. Renamed to omi_conversation_relevance_decision_total
and pinned by a test that reads the sidecar keep rule from the deploy YAML.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CodeQL flags the test's regex (py/redos, high): (?:\\s*#[^\\n]*)*\\s*
has nested quantifiers and \\s matches newlines, so adversarial input can
backtrack exponentially. Replace the comment-skipping regex with a linear
line filter — same behavior, no backtracking class.

Addresses CodeQL alert #359 on the new test file.
@Git-on-my-level
Git-on-my-level force-pushed the fix/relevance-metric-prefix branch from 817faba to f8fa134 Compare September 23, 2026 08:51
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Pushed f8fa134 — resolves the failing CodeQL check (alert #359, py/redos, high).

The test's name-extraction regex (?:\s*#[^\n]*)*\s* used nested quantifiers with \s (which also matches newlines), a pattern CodeQL flags for potential exponential backtracking. Replaced with a linear line-filter that skips comment-only lines between Counter( and the name literal — same extraction behavior, no backtracking class.

Verification: tests/unit/test_relevance_metric_is_scraped.py passes via the backend runner; full local pre-push gate passed (31 checks) against origin/main.

@Git-on-my-level
Git-on-my-level merged commit 0e9793f into main Sep 23, 2026
59 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/relevance-metric-prefix branch September 23, 2026 09:02
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.

2 participants