Weight service overview error rates by sample rate#195
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — makes the service-overview error rate sampling-aware so aggressively-retained error spans no longer over-represent the error rate under mixed per-span sampling.
- Weighted error aggregate in SQL — adds
estimatedErrorCount: sumIf(SampleRate, StatusCode = 'Error')inserviceOverviewQuery, mirroring the existingestimatedSpanCount: sum(SampleRate). - Domain type —
estimatedErrorCount: numberadded (required) toServiceOverviewOutputin both@maple/query-engineand@maple/domain; the HTTPServiceOverviewResponse.datais a passthroughRecord<string, unknown>so the field reaches clients without a schema change. - Client aggregation —
apps/web/src/api/warehouse/services.tsandapps/mobile/lib/api.tscomputeerrorRatefrom weighted errors/spans when every row in a group carries a finiteestimatedErrorCount, falling back to the raw retained-span rate otherwise (tolerates stale cached responses that predate the field). - Docs + tests —
docs/sampling-throughput.mdupdated to describe the weighting; tests cover the weighted (1/101), unsampled (weighted == raw), and stale-response fallback cases.
The change is correct and well-tested. estimatedErrorCount/estimatedSpanCount derive from sum(SampleRate) (Float64 → JSON number), so they sidestep the BYO-ClickHouse UInt64→string decode issue and the clients' Number() coercion covers both backends. The unsampled path is provably equivalent to the previous errorCount/spanCount behavior (all SampleRate = 1.0), the hasEstimatedErrors guard is conservatively all-or-nothing per group, and the totalEstimated > 0 fallback prevents divide-by-zero. Web and mobile implementations are identical. Nothing to change.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Claude Opus | 𝕏

Summary
estimatedErrorCountto service overview data from the query engine through mobile and web consumers.Testing