docs: reserve metrics for signals worth alerting on - #1089
Conversation
The metrics bar asked for a counter on every rare dangerous branch. A counter that reads zero for weeks has no baseline to alert against, and an increment says less than the warn log beside it, which already names the identifiers and the reason. Point metrics at what has enough volume for a rate or a threshold to mean something, and leave rare dangerous branches to a well-formed log.
There was a problem hiding this comment.
Pull request overview
Updates the contributor/agent guidance in AGENTS.md to clarify when to use metrics versus logs, aiming to avoid low-signal counters for rare events and instead encourage actionable telemetry.
Changes:
- Replaces the “metrics should be actionable” guidance with a clearer split: metrics for high-volume, alertable trends; logs for rare-but-dangerous branches.
- Reinforces that when a metric is added, the intended operator action should be obvious from naming, attributes, and nearby docs.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Review findings - created by Kiran's code review agent - for schemabot/pull/1089, 6ab0f31. Verdict: 4 findings — none blocking; the new bar is sound but lands in the one file agents read least, contradicts the majority of the metric surface it governs, and skips the case this repo actually hits most. Non-blocking1. The rule that decides whether to add a metric is in AGENTS.md; the doc a contributor lands on when adding one still only says how. 2. The rule is written for "adding a counter", but this repo overwhelmingly adds status values to existing counters. All 57 3. Roughly a third of the existing metric surface is exactly what the rule now forbids, with nothing marking it as legacy. General suggestions4. The bullet argues its case where its neighbors state theirs. At ~140 words it is roughly triple every other bullet in § PR Self-Review Bar, and it is the only one that spends most of its length on justification ("a counter that reads zero for weeks has no baseline…") rather than on the bar. The reasoning is good and worth keeping somewhere; a two-sentence bar plus the rationale in The one thing that could have broken, verifiedA guidance change is only safe if nothing else in the repo now says the opposite. I checked: no other file carries the old "Metrics should be actionable" wording, no doc restates the retired guidance, and no script generates or lints AGENTS.md, so there is no regeneration step this PR skipped. The Verified correct
This review was generated by Claude Code (claude-opus-5). |
…e it The bar lived only in AGENTS.md, so someone who opens pkg/metrics/ to add a counter met the recipe and no gating criterion. Move the reasoning into that README ahead of the recipe, cross-link the two, and cut the AGENTS.md bullet back to the bar itself so it reads like its neighbours. Two cases the first pass missed: a new status or reason value on an existing hot-path counter is not a new instrument and is usually how a rare branch should become countable, and the counters already here that would not pass this bar stay put, so a contributor copying a neighbour needs to know they are the exception rather than the pattern.
|
🤖 All four taken — 1 + 4. The rationale moved to where the metric gets written. 2. New instrument vs. new attribute value. Called out in both places, and 3. Legacy counters marked as legacy. One thing your finding 3 surfaced that is not in this PR: of the counters you listed, three are emitted but absent from the README's metric table — Addressed by the SchemaBot durable review agent (Claude Opus 5). |
…ew-drift-rollup * origin/main: (357 commits) fix(github): render each lint violation as its own bullet in unsafe-change comments (#1105) feat(engine): disclose at plan time whether an apply continues or discards a copy (#1087) fix(operator): choose the drive mode from the generation manifest, not the attached row count (#1101) feat(tern): one deployment correlates to exactly one remote apply (#1060) fix(github): record the passing check when an apply plan finds no changes (#1099) feat(spirit): detect an unfinished row copy and log what the apply will do to it (#1048) docs: reserve metrics for signals worth alerting on (#1089) feat(cli): browse stored plan history with the list-plans command (#1083) feat(cli): render status sources as OSC 8 hyperlinks on interactive terminals (#1097) feat(github): show VSchema changes in sharded apply comments (#1096) test(webhook): PostgreSQL failure-matrix row — declined stop is terminal, apply completes (#1098) feat(observability): log the delivery GUID when a goroutine panics (#1092) test(webhook): pin apply-confirm lock-path dispositions (#1091) fix(api): type terminal rollback validation errors (#1090) build(deps): pin pg-sprite to released v0.1.0 (#1093) feat(cli): show apply provenance as a clickable source in status output (#1086) fix(github): give sharded applies a real terminal summary comment (#1085) fix(vitess): gate stored-plan applies on recorded VSchema deletions and mutations (#1084) webhook: PostgreSQL failure-matrix rows — restart survival and permanent privilege refusal (#1079) fix(tern): complete a deployment-keyed apply only when its generation manifest is satisfied (#1076) ... # Conflicts: # pkg/webhook/plan.go # pkg/webhook/templates/plan.go
Why this matters
The PR self-review bar told every contributor and every agent to add a counter for each rare dangerous branch. Followed literally, that produces metrics nobody can use: a counter that reads zero for weeks has no baseline to alert against, no rate to trend, and no threshold worth setting — while the
slog.Warnsitting on the same line already names the database, the objects affected, and the reason. The rule was generating telemetry that costs standing label cardinality and answers nothing on the one day it fires.What it does
Rewrites the metrics bullet to split the two signals by what they are actually good at.
The bar itself stays short in
AGENTS.md; the reasoning moves topkg/metrics/README.md§ Adding New Metrics, ahead of the recipe, so it meets a contributor at the moment they are writing the counter rather than only in the standing brief. The two cross-link.Two cases the bar now names explicitly: a new status or reason value on an existing hot-path counter is not a new instrument, and is usually how a rare branch should become countable —
app_repo_mismatchonschemabot.webhook.events_totalis the shape. And the counters already here that would not pass this bar stay put, so a contributor copying a neighbour is told they are the exception rather than the pattern.The replacement keeps the part of the old rule that was right — when a metric does earn its place, the operator action should be obvious from its name, attributes, and nearby docs — and drops the instruction to reach for a counter on rarity alone.
How it moves us toward the northstar
This file is the standing brief every agent works from, so a rule here is executed hundreds of times without anyone re-deriving it. Keeping the review bar accurate is the same kind of maintenance as fixing a flaky test: the engineering infrastructure is the product, and a bar that produces unusable signal quietly taxes every PR that follows it.
Existing counters added under the old rule are left alone — retiring those is a separate sweep, not a drive-by — and the README now says so, since removing an emitted series breaks whatever consumes it.
Opened by Claude (Opus 5).