Files
ottyl/tickets/041-fix-string-metric-coercion.md
T

33 lines
1.3 KiB
Markdown

# 041 — Stop silently coercing string metric values to 1.0 in sum()/avg()
## Summary
`coerce_to_f64` (`src/engine.rs`) maps every `MetricPrimitive::String` value
to a flat `1.0`. This means `sum()`/`avg()` on a string-valued metric
silently becomes an occurrence count instead of erroring or behaving
predictably, with no signal to the user that their aggregate doesn't mean
what it looks like it means.
## Scope
- At PromQL query-evaluation time, detect when the target metric's declared
value kind is `String` and the requested aggregation is `sum`/`avg`.
- Either reject the query with a clear error ("cannot sum/avg a string-typed
metric; use count() or a numeric-typed metric"), or introduce an explicit
`count()` aggregation so occurrence-counting is something a user opts into
by name rather than something `sum()` does silently for the wrong metric
kind.
- Audit existing dashboards/panels for `sum()`/`avg()` over string-kind
metrics that would now be rejected or need updating to `count()`.
## Acceptance criteria
- Querying `sum()`/`avg()` over a string-kind metric either fails with a
clear, actionable error or is redirected to an explicit `count()` semantic
— it no longer silently returns a count while looking like a sum.
- Numeric-kind metrics are unaffected.
## Depends on
None.