Skip to content

Migrate unique_users_all_imports method from usage_data

Michał Wielich requested to merge michold-rm-usage-imports into master

What does this MR do and why?

Related to #421503 (closed)

Move two metrics from usage_data.rb into an instrumentation class

Screenshots or screen recordings

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

Before After

How to set up and validate locally

  1. If you don't have many imports done on your gdk, you can start by seeding it with some data. Here's an example script that can do that in the rails console (it's best to close it afterwards, as the FactoryBot inclusion messes with some things):
include FactoryBot::Syntax::Methods
create :jira_import_state, created_at: 3.days.ago
create :jira_import_state, created_at: 35.days.ago

create_list :group_import_state, 2, created_at: 3.days.ago
create_list :issue_csv_import, 3, created_at: 3.days.ago
create_list :bulk_import, 4, created_at: 3.days.ago
create_list :project, 5, import_type: :jira, created_at: 3.days.ago
  1. On master branch, open the rails console and generate a Service Ping: sp = Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
  2. Check out this MR's branch, run reload! in the console and then generate a new Service Ping: sp2 = Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
  3. Make sure that the values of the refactored metrics have not changed, by checking that this comparison returns true: [sp.dig(*'usage_activity_by_stage.manage.unique_users_all_imports'.split('.')), sp.dig(*'usage_activity_by_stage_monthly.manage.unique_users_all_imports'.split('.'))] == [sp2.dig(*'usage_activity_by_stage.manage.unique_users_all_imports'.split('.')), sp2.dig(*'usage_activity_by_stage_monthly.manage.unique_users_all_imports'.split('.'))]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michał Wielich

Merge request reports