Skip to content

fix(ws): keep watched pairs as metric labels, bound only the unknown ones - #426

Open
Miracle656 wants to merge 1 commit into
mainfrom
followup-pairlabel
Open

Miracle656 wants to merge 1 commit into
mainfrom
followup-pairlabel

Conversation

@Miracle656

Copy link
Copy Markdown
Collaborator

Follow-up to #401, which I merged. That PR closed the cardinality hole correctly — after it, no client-supplied string could mint a Prometheus series — but it folded every pair-specific subscription into other, which also removed all per-pair visibility. {pair="other"} and {pair="*"} together are barely more than one number, so "which pair actually has subscribers" stopped being answerable on the dashboard.

config.pairs is operator-defined and fixed for the lifetime of the process, which makes it a bounded label domain. So:

  • a subscription to a watched pair keeps its own label
  • everything else still collapses into other

The safety property is unchanged: the entire unbounded space is exactly one series.

On the test

The test environment configures no pairs at all, so config.pairs is empty and the watched-pair branch would never execute — the assertion would have passed for the wrong reason. The test stubs a single watched pair through vi.mock('../config') with importOriginal, because fanout.ts reads config.pairs once at module load.

src/__tests__/fanout.test.ts: 8 passed. tsc --noEmit clean.

Credit for the original fix and the metric-label test harness goes to @Jossy-ossy in #401 — this only refines the label domain.

https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB

…ones

#401 closed the cardinality hole in ws_clients_total /
ws_messages_sent_total / ws_messages_dropped_total by folding every
pair-specific subscription into `other`. That is safe — no client-supplied
string can mint a series — but it also costs all per-pair visibility:
{pair="other"} and {pair="*"} together are barely more than one number, so
"which pair actually has subscribers" stops being answerable.

config.pairs is operator-defined and fixed for the life of the process,
which makes it a bounded label domain. A subscription to a watched pair now
keeps its own label; everything else still collapses into `other`. The
safety property is unchanged: the whole unbounded space is one series.

The test environment configures no pairs, so the test stubs one — without
that the watched-pair branch is unreachable and the assertion would pass for
the wrong reason.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
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