Skip to content

feat(obs): a backend span can finally say WHICH button caused it (P7) - #503

Merged
athvin merged 1 commit into
mainfrom
bm/telemetry-p7-ui-action
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/telemetry-p7-ui-action

Conversation

@athvin

@athvin athvin commented Nov 5, 2026

Copy link
Copy Markdown
Owner

What

The trace already reached from a click to every SQL statement a run executed.
What it could not say is which control started it — a reader looking at a
slow statement could see it belonged to some click and had to walk up to the
root span to find out which. The question people actually ask, "what does the
Merge button do to the database?"
, needs the control's name on the backend
span
.

So the declared action travels browser → BFF → erserver as x-er-action,
beside the traceparent that was already going. One header, three hops, and
er.action on http.server.

Three deliberate choices

Shape-validated in erserver, not membership-checked. The authoritative
vocabulary is TypeScript; duplicating UI_ACTIONS in Rust would create a
two-language list that drifts silently in whichever direction nobody is testing.
check-er-actions.mjs is the real guarantee — this is the untrusted-input bound
underneath it.

Shape is enough for what it has to prevent. Lowercase, digits, dots and
underscores with at least one dot refuses every payload shape that matters in a
deduplication engine: an email carries @, a record key carries uppercase or
hyphens, a query string carries = and &. The test asserts that against
real strings from this app's own markup, including the
[email protected] testid and the Remove [email protected]
aria-label that caused the PII fix in #484, plus a header-splitting attempt.

Validated again at the BFF, against the real vocabulary. The browser is not
trusted, and an unrecognised name is either a typo the gate should have caught
or something hostile. Dropping it is right either way, because an action name
reaches a span store.

Span-only, never a metric dimension. The vocabulary grows with the UI, and a
per-action series is the cardinality mistake §10 already priced at ~$131/month
for one histogram. A per-action aggregate, if ever wanted, is a spanmetrics
connector in the collector's values file — YAML, revertible, no Rust change.

What is NOT sent

The background root, because it is not something anybody did and sending it
would make "no click" indistinguishable from a declared action in any grouping.
And a lapsed action: a poll firing a second after a click gets none, which
the TTL test asserts.

The seventh sampling policy

This makes ui-interactions possible — the one policy the plan listed that has
been absent, because there was no attribute to key on.

A click causing a mutation was already kept by mutations, one starting a run
by pipeline-runs. What fell through was the click that causes a GET —
opening a record, filtering the inbox, paging a table — which landed in
residual and was therefore dropped 90% of the time. That is the half of
the click stream most likely to be asked about ("what did this person look at
before they merged these two?"), and its volume is tiny next to the read path it
sits in.

tail_sampling now carries all seven policies in the plan's order, residual
last.

Verification

  • make check → exit 0
  • pnpm check → exit 0, 874 tests, 13 declared actions all emitted
  • 5 telemetry unit tests, including the hostile-input set above

🤖 Generated with Claude Code

The trace already reached from a click to every SQL statement a run executed.
What it could not say is which control started it: a reader looking at a slow
statement could see it belonged to some click, and had to walk up to the root
span to find out which. The question people actually ask — "what does the
Merge button do to the database?" — needed the control's name ON the backend
span.

So the declared action travels browser -> BFF -> erserver as `x-er-action`,
beside the `traceparent` that was already going. One header, three hops, and
`er.action` on `http.server`.

Three deliberate choices:

**Shape-validated in erserver, not membership-checked.** The authoritative
vocabulary is TypeScript, and duplicating `UI_ACTIONS` in Rust would create a
two-language list that drifts silently in whichever direction nobody is
testing. The build gate is the real guarantee; this is the untrusted-input
bound underneath it. Shape is enough for what it must prevent: lowercase,
digits, dots and underscores with at least one dot refuses every payload shape
that matters here, because an email carries `@`, a record key carries
uppercase or hyphens, and a query string carries `=` and `&`. The test asserts
that against real strings from this app's own markup — including the
`[email protected]` testid and the `Remove [email protected]`
aria-label that caused the PII fix in #484.

**Validated again at the BFF, against the real vocabulary.** The browser is
not trusted, and an unrecognised name is either a typo the er-actions gate
should have caught or something hostile. Dropping it is right in both cases,
because an action name reaches a span store.

**Span-only, never a metric dimension.** The vocabulary grows with the UI, and
a per-action series is the cardinality mistake §10 already priced at
~$131/month for one histogram. A per-action aggregate, if ever wanted, is a
`spanmetrics` connector in the collector's values file.

The background root is NOT sent. It is not something anybody did, and sending
it would make "no click" indistinguishable from a declared action in any
grouping. Nor is a lapsed one: a poll firing a second after a click gets no
action, which the TTL test asserts.

This also makes the seventh tail_sampling policy possible, which the plan
listed and which has been absent because there was no attribute to key on. A
click causing a mutation was already kept by `mutations` and one starting a
run by `pipeline-runs`; what fell through was the click causing a GET —
opening a record, filtering the inbox, paging a table — which landed in
`residual` and was dropped 90% of the time. That is the half of the click
stream most likely to be asked about, and its volume is tiny next to the read
path it sits in.

make check exit 0; pnpm check exit 0, 874 tests, 13 declared actions all
emitted.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit 6f5cc74 into main Nov 5, 2026
42 checks passed
@athvin
athvin deleted the bm/telemetry-p7-ui-action branch November 5, 2026 12:45
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