Skip to content

fix: histogram clickhouse calculation#2567

Merged
StarpTech merged 1 commit intomainfrom
dustin/eng-9047-histogram-quantile-interpolation-over-estimates-latency
Feb 27, 2026
Merged

fix: histogram clickhouse calculation#2567
StarpTech merged 1 commit intomainfrom
dustin/eng-9047-histogram-quantile-interpolation-over-estimates-latency

Conversation

@StarpTech
Copy link
Copy Markdown
Contributor

@StarpTech StarpTech commented Feb 27, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed histogram quantile interpolation calculation to improve accuracy of metric computations.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 27, 2026

Walkthrough

Two ClickHouse migrations address a bug in the func_histogram_v2 function used for Prometheus bucket_quantile interpolation. The first migration drops the existing buggy function; the second recreates it with corrected interpolation logic using the proper Prometheus formula.

Changes

Cohort / File(s) Summary
ClickHouse Migrations
controlplane/clickhouse/migrations/20260227100333_drop_func_histogram_v2.sql, controlplane/clickhouse/migrations/20260227100342_recreate_func_histogram_v2_fix_interpolation.sql
Drop and recreate func_histogram_v2 function with corrected Prometheus bucket_quantile interpolation. The function previously used an incorrect interpolation fraction (rank / cumSum[b]); the fix implements the proper formula: lowerBound + (upperBound - lowerBound) * (rank - cumSum[b-1]) / (cumSum[b] - cumSum[b-1]) for the main interpolation case, with separate handling for boundary conditions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'fix: fix histogram clickhouse calculation' clearly describes a bugfix for histogram calculations in ClickHouse, which directly relates to the PR's main objective of fixing interpolation logic in the func_histogram_v2 function.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

Comment @coderabbitai help to get the list of available commands and usage tips.

@StarpTech StarpTech changed the title fix: fix histogram clickhouse calculation fix: histogram clickhouse calculation Feb 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.59%. Comparing base (1393f43) to head (7bc0eb2).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2567   +/-   ##
=======================================
  Coverage   63.59%   63.59%           
=======================================
  Files         298      298           
  Lines       41920    41920           
  Branches     4439     4439           
=======================================
  Hits        26657    26657           
  Misses      15241    15241           
  Partials       22       22           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@wilsonrivera wilsonrivera left a comment

Choose a reason for hiding this comment

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

LGTM

@StarpTech StarpTech merged commit 9b69e59 into main Feb 27, 2026
13 checks passed
@StarpTech StarpTech deleted the dustin/eng-9047-histogram-quantile-interpolation-over-estimates-latency branch February 27, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants