Skip to content

Weight service overview error rates by sample rate#195

Open
Makisuo wants to merge 1 commit into
mainfrom
codex/fix-overview-error-values
Open

Weight service overview error rates by sample rate#195
Makisuo wants to merge 1 commit into
mainfrom
codex/fix-overview-error-values

Conversation

@Makisuo

@Makisuo Makisuo commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add estimatedErrorCount to service overview data from the query engine through mobile and web consumers.
  • Compute overview error rates from weighted error spans when reliable sampling weights are available, with a fallback to raw retained-span rates.
  • Update sampling documentation to describe the new error-rate behavior.
  • Expand tests to cover weighted, unsampled, and stale-response cases.

Testing

  • Added unit tests for the query engine SQL shape.
  • Added unit tests for service overview aggregation in the web and mobile clients.

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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') in serviceOverviewQuery, mirroring the existing estimatedSpanCount: sum(SampleRate).
  • Domain typeestimatedErrorCount: number added (required) to ServiceOverviewOutput in both @maple/query-engine and @maple/domain; the HTTP ServiceOverviewResponse.data is a passthrough Record<string, unknown> so the field reaches clients without a schema change.
  • Client aggregationapps/web/src/api/warehouse/services.ts and apps/mobile/lib/api.ts compute errorRate from weighted errors/spans when every row in a group carries a finite estimatedErrorCount, falling back to the raw retained-span rate otherwise (tolerates stale cached responses that predate the field).
  • Docs + testsdocs/sampling-throughput.md updated 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.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Claude Opus𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant