fix(reports): count only rows that have a value for the selected metric - #4478
Open
JeremieSamson wants to merge 1 commit into
Open
JeremieSamson wants to merge 1 commit into
JeremieSamson wants to merge 1 commit into
Conversation
The performance report showed count(*) next to percentiles computed with percentile_cont/quantile, which skip NULL rows. Web Vitals are sparse: CLS and INP are Chromium-only, so most pageviews carry no value for them. The UI labels this number "sample size", so it claims to describe the population behind the displayed percentile. On a real instance over 14 days it reported 1681 for an INP p75 actually computed from 112 rows. Counting the selected metric column instead makes the number match the percentile it sits next to. The metric name is validated by a zod enum, and the columns are nullable on both engines.
|
@JeremieSamson is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile SummaryThis PR aligns reported Web Vital sample sizes with the non-null observations used to calculate percentile values.
Confidence Score: 5/5The PR appears safe to merge, with no actionable correctness, security, or compatibility issues identified. The selected metric is constrained to known nullable Web Vital columns, and both database implementations now count the same non-null population their percentile aggregates use.
|
| Filename | Overview |
|---|---|
| src/queries/sql/reports/getPerformance.ts | Counts non-null values for the selected Web Vital in both PostgreSQL and ClickHouse summary queries, matching percentile populations. |
| src/queries/sql/reports/getPerformanceMetrics.ts | Counts non-null selected-metric values in grouped performance queries across both supported database engines. |
Reviews (1): Last reviewed commit: "fix(reports): count only rows that have ..." | Re-trigger Greptile
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.
Problem
In the performance report, the sample size shown next to a Web Vital does not
describe that metric.
getPerformanceandgetPerformanceMetricscompute percentiles withpercentile_cont(...) within group (order by <metric>)(Postgres) andquantile(...)(<metric>)(ClickHouse). Both skip NULL rows. The count next tothem is
count(*)/count(), which does not.Web Vitals are sparse. CLS and INP are Chromium-only, so Safari, iOS and
Firefox pageviews store a
website_eventrow withevent_type = 5and novalue for those columns. The two numbers therefore describe different
populations.
This is visible in the UI, which labels the number
sampleSize:Evidence
Self-hosted instance, Postgres, one website, 14 days,
event_type = 5:So the report claims an INP p75 of 88 ms over 1681 samples, when 112 rows
carry an INP value. The smaller the coverage, the more confident the number
looks.
Fix
Count the selected metric column instead of every row:
Same change on both engines, in
getPerformance.ts(thesummarythe UIlabels "sample size") and in
getPerformanceMetrics.ts(thecountreturnedfor pages, titles, devices and browsers).
Verified on the same data:
Notes
metricis validated byz.enum(['lcp','inp','cls','fcp','ttfb'])inschema.ts, so interpolating it here is no different from the existingpercentile expressions in the same queries.
count(column)excludes missing values on ClickHouse as well as on Postgres.
metric: selectedMetricis part of the query parameters), so the summary countfollows the selection with no UI change.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.