GraphQL: Add durationStatistics to AnalyticsPeriodType

What does this MR do and why?

This MR adds a durationStatistics field to AnalyticsPeriodType as an alpha field. This will allow computing the mean duration of pipelines in #454310 (closed).

Changelog: added

Closes #454310 (closed)

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Go to the shell in your GDK gitlab directory and run bundle exec rake "gitlab:seed:runner_fleet". This will seed your GDK with some pipelines and jobs required for testing this MR.

  2. Open http://gdk.test:3000/-/graphql-explorer

  3. Execute the following query:

    {
      project(fullPath: "rf-top-level-group-1/rf-group-1.1/rf-group-1.1.1/rf-project-1-1-1-1") {
        pipelineAnalytics {
          aggregate {
            durationStatistics {
              p50
              p75
              p90
              p95
              p99
            }
          }
        }
      }
    }

You should obtain the requested statistics from the pipelines in the specified group, as demonstrated in the screenshot above.

ClickHouse query produced

SELECT quantileMerge (0.5) (ci_finished_pipelines_hourly.duration_quantile) AS p50, quantileMerge (0.75)
  (ci_finished_pipelines_hourly.duration_quantile) AS p75, quantileMerge (0.9)
  (ci_finished_pipelines_hourly.duration_quantile) AS p90, quantileMerge (0.95)
  (ci_finished_pipelines_hourly.duration_quantile) AS p95,
  quantileMerge (0.99) (ci_finished_pipelines_hourly.duration_quantile) AS p99
FROM ci_finished_pipelines_hourly
WHERE (path = '94/96/98/101/')
  AND (ci_finished_pipelines_hourly.started_at_bucket >= toDateTime64 ('2024-09-09 14:44:15', 6, 'UTC'))
  AND (ci_finished_pipelines_hourly.started_at_bucket < toDateTime64 ('2024-09-16 14:44:15', 6, 'UTC'))
Edited by Max Fan

Merge request reports

Loading