Skip to content

Cycle Analytics implement event query customization

What does this MR do?

  • Reimplements old CA event queries within StageEvents.
  • Extends the stage events concept with timestamp_projection and apply_query_customization methods.
  • Basic tests for stage events.

Note 1: This MR doesn't provide new features, there are no user facing changes. The original MR was split from CE to help the review process.

Note 2: Some StageEvents have complex AR queries that are not tested in this MR. Tests will be added in the next MR with the stage query tests (MR: !16775 (merged)).

What is Cycle Analytics

Note: CA feature (legacy) is already implemented and working, the new phase of the development is implement bugfixes and to allow customization of the stages. The current CA implementation in GitLab provides 7 stages, we are reimplementing them using the new backend (and later remove the old implementation).

  • Current (old) Feature documentation
  • New backend and customization issue
  • Find records (MergeRequest or Issue) between two, pre-defined timestamp columns (start_event - end_event) = Stage
    • Calculate metrics
    • Example: How long did it take to get to issue create to issue close? (issues.closed_at - issues.created_at)
  • Some events are not possible to combine together, these rules are expressed in lib/gitlab/analytics/cycle_analytics/stage_events.rb
  +---------------------+
  | Stages              |
  |   +-------------+   |
  |   |   Stage A   |   | 
  |   |             |   | 
  |   +-------------+   |  
  |   | Start Event |   |
  |   +-------------+   |    
  |   | End Event   |   |   
  |   +-------------+   | 
  |                     |
  |   +-------------+   |
  |   |   Stage B   |   |
  |   |             |   |
  |   +-------------+   |
  |   | Start Event |   |
  |   +-------------+   |
  |   | End Event   |   |
  |   +-------------+   |
  |                     |
  |   ...               |
  +---------------------+

How StageEvents work

  • A StageEvent is tied to MergeRequest or Issue models (object_type method). Example: IssueCreated event only makes sense in context of the Issue model.
  • There is a BaseQuery that provides the initial ActiveRecord scope (not implemented in this MR).
  • When the query is executed, the start_event and end_event applies their query customizations.
    • Some events might require joining another table, or additional filtering conditions are needed. Example: IssueFirstMentionedInCommit
  • For the metrics, timestamp_projection method provides a way to calculate duration between start and end events (not implemented in this MR). It exposes a timestamp expression.
    • Example calculation: Issue first mentioned in commit - Issue created = duration
    • We are planning to calculate duration per record and the median for a list of records, see screenshot below.

Screenshots

cycle-analytics-view

Does this MR meet the acceptance criteria?

Conformity

Edited by 🤖 GitLab Bot 🤖

Merge request reports