Commit a0ca8583 authored by Marc Shaw's avatar Marc Shaw

Aggregate certain usage metrics for code review

MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53553
parent 04da813f
---
name: usage_data_code_review_aggregation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53553
rollout_issue_url:
milestone: '13.9'
type: development
group: group::code review
default_enabled: false
# code_review_extension_category_monthly_active_users
# This is only metrics related to the VS Code Extension for now.
#
# code_review_category_monthly_active_users
# This is the user based metrics. These should only be user based metrics and only be related to the Code Review things inside of GitLab.
#
# code_review_group_monthly_active_users
# This is an aggregation of both of the above aggregations. It's intended to represent all users who interact with our group across all of our categories.
---
- name: code_review_group_monthly_active_users
operator: OR
feature_flag: usage_data_code_review_aggregation
source: redis
events: [
'i_code_review_user_single_file_diffs',
'i_code_review_user_create_mr',
'i_code_review_user_close_mr',
'i_code_review_user_reopen_mr',
'i_code_review_user_resolve_thread',
'i_code_review_user_unresolve_thread',
'i_code_review_edit_mr_title',
'i_code_review_edit_mr_desc',
'i_code_review_user_merge_mr',
'i_code_review_user_create_mr_comment',
'i_code_review_user_edit_mr_comment',
'i_code_review_user_remove_mr_comment',
'i_code_review_user_create_review_note',
'i_code_review_user_publish_review',
'i_code_review_user_create_multiline_mr_comment',
'i_code_review_user_edit_multiline_mr_comment',
'i_code_review_user_remove_multiline_mr_comment',
'i_code_review_user_add_suggestion',
'i_code_review_user_apply_suggestion',
'i_code_review_user_assigned',
'i_code_review_user_review_requested',
'i_code_review_user_approve_mr',
'i_code_review_user_unapprove_mr',
'i_code_review_user_marked_as_draft',
'i_code_review_user_unmarked_as_draft',
'i_code_review_user_approval_rule_added',
'i_code_review_user_approval_rule_deleted',
'i_code_review_user_approval_rule_edited',
'i_code_review_user_vs_code_api_request',
'i_code_review_user_toggled_task_item_status',
'i_code_review_user_create_mr_from_issue'
]
- name: code_review_category_monthly_active_users
operator: OR
feature_flag: usage_data_code_review_aggregation
source: redis
events: [
'i_code_review_user_single_file_diffs',
'i_code_review_user_create_mr',
'i_code_review_user_close_mr',
'i_code_review_user_reopen_mr',
'i_code_review_user_resolve_thread',
'i_code_review_user_unresolve_thread',
'i_code_review_edit_mr_title',
'i_code_review_edit_mr_desc',
'i_code_review_user_merge_mr',
'i_code_review_user_create_mr_comment',
'i_code_review_user_edit_mr_comment',
'i_code_review_user_remove_mr_comment',
'i_code_review_user_create_review_note',
'i_code_review_user_publish_review',
'i_code_review_user_create_multiline_mr_comment',
'i_code_review_user_edit_multiline_mr_comment',
'i_code_review_user_remove_multiline_mr_comment',
'i_code_review_user_add_suggestion',
'i_code_review_user_apply_suggestion',
'i_code_review_user_assigned',
'i_code_review_user_review_requested',
'i_code_review_user_approve_mr',
'i_code_review_user_unapprove_mr',
'i_code_review_user_marked_as_draft',
'i_code_review_user_unmarked_as_draft',
'i_code_review_user_approval_rule_added',
'i_code_review_user_approval_rule_deleted',
'i_code_review_user_approval_rule_edited',
'i_code_review_user_toggled_task_item_status',
'i_code_review_user_create_mr_from_issue'
]
- name: code_review_extension_category_monthly_active_users
operator: OR
feature_flag: usage_data_code_review_aggregation
source: redis
events: [
'i_code_review_user_vs_code_api_request'
]
......@@ -223,7 +223,7 @@ RSpec.describe Gitlab::Usage::Metrics::Aggregates::Aggregate, :clean_gitlab_redi
end
it 'allows for YAML aliases in aggregated metrics configs' do
expect(YAML).to receive(:safe_load).with(kind_of(String), aliases: true)
expect(YAML).to receive(:safe_load).with(kind_of(String), aliases: true).at_least(:once)
described_class.new(recorded_at)
end
......
# frozen_string_literal: true
require 'spec_helper'
# If this spec fails, we need to add the new code review event to the correct aggregated metric
RSpec.describe 'Code review events' do
it 'the aggregated metrics contain all the code review metrics' do
wildcard = Gitlab::Usage::Metrics::Aggregates::AGGREGATED_METRICS_PATH
aggregated_events = Dir[wildcard].each_with_object([]) do |path, metrics|
metrics.push(*YAML.safe_load(File.read(path), aliases: true)&.map(&:with_indifferent_access))
end
code_review_aggregated_events = aggregated_events
.select { |event| event['name'].include?('code_review') }
.map { |event| event['events'] }
.flatten
.uniq
code_review_events = Gitlab::UsageDataCounters::HLLRedisCounter.events_for_category("code_review")
exceptions = %w[i_code_review_mr_diffs i_code_review_mr_single_file_diffs]
code_review_aggregated_events += exceptions
expect(code_review_events - code_review_aggregated_events).to be_empty
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment