Skip to content

Migrate epic events to internal events: vol.5

Michał Wielich requested to merge michold-epic-migr-vol5 into master

What does this MR do and why?

Related to #421593 (closed)

Migrate some of the redis_hll_counters.epics_usage.epics_usage_total_unique_counts_monthly event's sub-events to Internal Events API.

Script used to update the files:
class DebugGenerator < Gitlab::Analytics::InternalEventsGenerator
  source_root File.expand_path('generator_templates/gitlab_internal_events', __dir__)

  def create_metric_file
    validate!

    template "event_definition.yml",
      event_file_path(event),
      options.fetch(:event_desc)
  end

  def milestone
    "16.5"
  end
end

is_ee = true
mr_number = 132027
unique_by = "user.id"
section = "dev"
stage = "plan"
group = "product_planning"
events_with_desc = [
['g_project_management_users_setting_epic_confidential', "An epic has been set to confidential"],
['g_project_management_users_setting_epic_visible', "An epic has been set to visible"],
['g_project_management_epic_users_changing_labels', "An epic's labels have been changed'"],
['g_project_management_epic_destroyed', "An epic has been destroyed"],
['project_management_users_checking_epic_task', "An epic task has been checked"],
['project_management_users_unchecking_epic_task', "An epic task has been unchecked"],
]


events_with_desc.each do |event_name, event_desc|
  tiers = is_ee ? %w[premium ultimate] : %w[free premium ultimate]
  DebugGenerator.new([], {
    event: event_name,
    event_desc: event_desc,
    section: section,
    stage: stage,
    group: group,
    mr: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/#{mr_number}",
    unique: unique_by,
    tiers: tiers
  }).invoke_all
  ['28d', '7d'].each do |days|
    dir_prefix = is_ee ? "ee/" : ""
    event_file_pattern = event_name.delete_prefix('g_project_management_')
    event_file_pattern = event_file_pattern.delete_prefix('users_setting_')
    event_file_pattern = event_file_pattern.gsub('epic_users_changing_labels', 'epic_labels')

    files = Dir["#{dir_prefix}config/metrics/counts_#{days}/*\_#{event_file_pattern}\_*"]
    raise StandardError, "Multiple files found: #{files}" unless files.count == 1
    file_name = files.first

    text = File.read(file_name)
    new_contents = text.gsub(/distribution:/, "events:
  - name: #{event_name}
    unique: #{unique_by}\ndistribution:")
    new_contents = new_contents.gsub(/data_source: redis_hll/, "data_source: internal_events")

    File.open(file_name, "w") {|file| file.puts new_contents }
  end
end

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. Enable snowplow micro
  2. Trigger any of the events migrated here:
  • set an epic as confidential
  • set an epic as non-confidential
  • change an epic's labels
  • delete an epic
  • set an epic's task as checked
  • set an epic's task as unchecked
  1. Make sure that the events have been triggered with content as per their new event definition files [eg. - category sent as InternalEventTracking] on the http://localhost:9091/micro/good snowplow micro endpoint.

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