Repository navigation
feat(obs): a backend span can finally say WHICH button caused it (P7) - #503
Merged
Merged
Conversation
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]>
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
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
traceparentthat was already going. One header, three hops, ander.actiononhttp.server.Three deliberate choices
Shape-validated in erserver, not membership-checked. The authoritative
vocabulary is TypeScript; duplicating
UI_ACTIONSin Rust would create atwo-language list that drifts silently in whichever direction nobody is testing.
check-er-actions.mjsis the real guarantee — this is the untrusted-input boundunderneath 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 orhyphens, a query string carries
=and&. The test asserts that againstreal strings from this app's own markup, including the
[email protected]testid and theRemove [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
spanmetricsconnector 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-interactionspossible — the one policy the plan listed that hasbeen absent, because there was no attribute to key on.
A click causing a mutation was already kept by
mutations, one starting a runby
pipeline-runs. What fell through was the click that causes a GET —opening a record, filtering the inbox, paging a table — which landed in
residualand was therefore dropped 90% of the time. That is the half ofthe 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_samplingnow carries all seven policies in the plan's order,residuallast.
Verification
make check→ exit 0pnpm check→ exit 0, 874 tests, 13 declared actions all emittedtelemetryunit tests, including the hostile-input set above🤖 Generated with Claude Code