feat(slo): let an SLI attach labels only it can supply - #14
Open
chris13524 wants to merge 1 commit into
Open
chris13524 wants to merge 1 commit into
chris13524 wants to merge 1 commit into
Conversation
`labelled(sli, expr)` now applies an SLI's optional `decorate(expr)` outermost, after all the burn arithmetic. Optional and guarded, so an SLI that does not define it takes exactly the previous code path. The placement is the point, not an implementation detail. PromQL binary ops match on the full label set, so a label added to `bad` but not to the budget built from `events` yields no series at all — a silently empty rule rather than an error. Wrapping at the end also applies it once per rule instead of once per window, which matters because these expressions are already near the size where Amazon Managed Grafana's rule-group writes get flaky. Complements #13 rather than overlapping it. That PR gave the caller `dimension_template` to PRINT a dimension label; this gives an SLI a way to CREATE one. blockchain-api uses the pair together: its per-chain SLIs aggregate `by (chain_id)`, `decorate` maps each id to the human chain name from chain_config.json, and `dimension_template` renders "Avalanche C-Chain (eip155:43114)" instead of the CAIP-2 id alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
labelled(sli, expr)now applies an SLI's optionaldecorate(expr)outermost, after all the burn arithmetic. Guarded withstd.objectHasAll, so an SLI that doesn't define it takes exactly the previous code path.Why outermost
This is the point of the change, not an implementation detail.
PromQL binary ops match on the full label set. A label added to
badbut not to the budget built fromeventstherefore produces no series at all — a silently empty rule, not an error. Outermost is the only placement where a decoration cannot break the arithmetic it decorates.It also applies the decoration once per rule instead of once per window. These expressions are already near the size where AMG's
PutAlertRuleGroupgets flaky, so a per-window copy of a 31-entry label map would be expensive.Relationship to #13
Complementary, not overlapping — I checked before writing this.
dimension_template, to print a dimension label.blockchain-api uses the pair together: its per-chain SLIs aggregate
by (chain_id),decoratemaps each id to the human chain name fromchain_config.json, anddimension_templatethen rendersAvalanche C-Chain (eip155:43114)rather than the CAIP-2 id alone. Companion PR in blockchain-api.Backwards compatibility — verified, not assumed
Both consumers were rendered with and without the change:
SUCCESS, unchangedalerts.jsonnetSUCCESS🤖 Generated with Claude Code