Skip to content

Commit a616cab

Browse files
authored
Update percentiles query to use WITHIN GROUP (#1046)
1 parent 88f286b commit a616cab

File tree

1 file changed

+5
-5
lines changed
  • docs/integrations/web-frameworks

1 file changed

+5
-5
lines changed

docs/integrations/web-frameworks/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ Here is a sample query to compute those percentiles for HTTP requests duration:
5959
WITH dataset AS (
6060
SELECT
6161
time_bucket('%time_bucket_duration%', start_timestamp) AS x,
62-
(extract(ms from end_timestamp - start_timestamp)) as duration_ms
62+
duration * 1000 as duration_ms
6363
FROM records
6464
WHERE attributes ? 'http.method'
6565
)
6666
SELECT
6767
x,
68-
approx_percentile_cont(duration_ms, 0.50) as percentile_50,
69-
approx_percentile_cont(duration_ms, 0.90) as percentile_90,
70-
approx_percentile_cont(duration_ms, 0.95) as percentile_95,
71-
approx_percentile_cont(duration_ms, 0.99) as percentile_99
68+
approx_percentile_cont(0.50) WITHIN GROUP (ORDER BY duration_ms) as percentile_50,
69+
approx_percentile_cont(0.90) WITHIN GROUP (ORDER BY duration_ms) as percentile_90,
70+
approx_percentile_cont(0.95) WITHIN GROUP (ORDER BY duration_ms) as percentile_95,
71+
approx_percentile_cont(0.99) WITHIN GROUP (ORDER BY duration_ms) as percentile_99
7272
FROM dataset
7373
GROUP BY x
7474
ORDER BY x

0 commit comments

Comments
 (0)