Repository navigation
fix(grafana): exclude PRs without a metrics row from PR time panels - #9226
Open
chenwei791129 wants to merge 1 commit into
Open
chenwei791129 wants to merge 1 commit into
chenwei791129 wants to merge 1 commit into
Conversation
The PR time panels of the Engineering Throughput and Cycle Time dashboards (and the team view) LEFT JOIN project_pr_metrics and coalesce the metric to 0, so a merged PR without a project_pr_metrics row was averaged in as 0 hours. Projects without DORA enabled showed a flat 0 h on every panel. Inner join project_pr_metrics in the MySQL and PostgreSQL variants so those PRs are excluded. Projects where every merged PR has a row get the same values as before, and NULL sub-metrics within a row are still treated as 0. Closes apache#9225
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.
Summary
The five PR time panels (PR Cycle / Coding / Pickup / Review / Deploy Time) of Engineering Throughput and Cycle
Time and its Team View take merged PRs from
pull_requests,LEFT JOIN project_pr_metrics, andcoalesce(..., 0)the metric. A merged PR without aproject_pr_metricsrow was therefore averaged in as0 hours. For a project without DORA enabled, every panel showed a flat 0 h.
This PR changes
LEFT JOIN project_pr_metricstoJOINin those 20 queries (2 dashboards × 5 panels ×MySQL/PostgreSQL). Nothing else in the SQL changes.
coalesce(..., 0)is kept on purpose. A row can still have a NULL coding, pickup, review or deploy time, andthose values are still treated as 0. All five panels still average over the same set of PRs.
grafana/scripts/convert-mysql-to-postgresql.pyon the updated MySQL file. The PostgreSQL team view alreadydiffers from the converter output (it uses
${team1:csv}instead of${team1:singlequote}), so regeneratingit would undo those edits.
Does this close any open issues?
Closes #9225
Screenshots
No layout changes. Query results are shown under Tests.
Other Information
Not changed here: the join matches on
pr.idonly, while the primary key ofproject_pr_metricsis(id, project_name). Every dashboard that reads this table joins the same way.Tests
There are no automated tests for dashboard SQL. I ran the 10 panel queries from
mainand from this branchagainst MySQL 8 and PostgreSQL 17 with synthetic data, replacing the Grafana macros with literal values:
mainpqfullmainon all 10 panelsThe results are the same on MySQL and PostgreSQL, for both dashboards. All four JSON files parse.