Skip to content

fix(grafana): exclude PRs without a metrics row from PR time panels - #9226

Open
chenwei791129 wants to merge 1 commit into
apache:mainfrom
chenwei791129:fix/dashboard-pr-metrics-missing-row
Open

chenwei791129 wants to merge 1 commit into
apache:mainfrom
chenwei791129:fix/dashboard-pr-metrics-missing-row

Conversation

@chenwei791129

Copy link
Copy Markdown
Contributor

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, and
coalesce(..., 0) the metric. A merged PR without a project_pr_metrics row was therefore averaged in as
0 hours. For a project without DORA enabled, every panel showed a flat 0 h.

This PR changes LEFT JOIN project_pr_metrics to JOIN in those 20 queries (2 dashboards × 5 panels ×
MySQL/PostgreSQL). Nothing else in the SQL changes.

Case Before After
Some merged PRs have no row Averaged in as 0 h, pulling the average down Excluded
No PR has a row (e.g. DORA disabled) Flat 0 h No data
Every merged PR has a row (DORA enabled) — Unchanged
  • coalesce(..., 0) is kept on purpose. A row can still have a NULL coding, pickup, review or deploy time, and
    those values are still treated as 0. All five panels still average over the same set of PRs.
  • The PostgreSQL files are edited by hand. For the main dashboard, the result is identical to running
    grafana/scripts/convert-mysql-to-postgresql.py on the updated MySQL file. The PostgreSQL team view already
    differs from the converter output (it uses ${team1:csv} instead of ${team1:singlequote}), so regenerating
    it 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.id only, while the primary key of project_pr_metrics is
(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 main and from this branch
against MySQL 8 and PostgreSQL 17 with synthetic data, replacing the Grafana macros with literal values:

Project Data main This PR
p 2 PRs with rows (cycle time 14 h and 10 h), 1 PR without PR Cycle Time 8 h 12 h
q Merged PR, no rows (DORA disabled) 0 h on all 10 panels No rows (No data)
full Every PR has a row — Same as main on all 10 panels

The results are the same on MySQL and PostgreSQL, for both dashboards. All four JSON files parse.

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
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.

[Bug][Dashboard] Engineering Throughput PR time panels count PRs without a project_pr_metrics row as 0 hours

1 participant