Skip to content

Migrate i_code_review_create_mr to total counts

What does this MR do and why?

In the past the only timed framed metric we supported could count unique values. The creative implementor of redis_hll_counters.code_review.i_code_review_create_mr_weekly and redis_hll_counters.code_review.i_code_review_create_mr_monthly wanted to count the number of merge requests created in the last 7 and 28 days. They achieved that by counting a value that is guaranteed to be unique - namely the id of the merge request. Very creative 👍

Now that we support simple counters with time frames we want to migrate this metric to Internal Events.

This MR does a few things:

  1. Change the metric definitions to use the i_code_review_user_create_mr event instead of i_code_review_create_mr. i_code_review_user_create_mr already has an event definition and we only need one event now.
  2. Removes usage of i_code_review_create_mr
  3. Migrate the values of the weekly keys e.g. {hll_counters}_i_code_review_create_mr-2023-49 to {event_counters}_i_code_review_user_create_mr-2023-49

Notice that the new keys doesn't have an expiry date. This is a general issue for TotalCounterMetric which is covered in #433502 (closed)

How to set up and validate locally

Make sure you start on master

Prerequisites

Run the monitor rails runner scripts/internal_events/monitor.rb i_code_review_create_mr and make sure that both metrics are reporting a strictly positive value.

If the metrics are reporting 0, you can add some values like this:

gdk redis-cli pfadd '{hll_counters}_i_code_review_create_mr-2023-50' 1 2 3
gdk redis-cli pfadd '{hll_counters}_i_code_review_create_mr-2023-49' 4 5 6
gdk redis-cli pfadd '{hll_counters}_i_code_review_create_mr-2023-48' 7 8
gdk redis-cli pfadd '{hll_counters}_i_code_review_create_mr-2023-47' 9 10
gdk redis-cli pfadd '{hll_counters}_i_code_review_create_mr-2023-46' 11 12 13

Steps to verify

  1. Checkout master
  2. Run the monitor rails runner scripts/internal_events/monitor.rb i_code_review_create_mr and note down the values for the two RedisHLLMetrics.
  3. Checkout the new branch
  4. Run the migrations bundle exec rake db:migrate
  5. Verify that the new keys are created `gdk redis-cli keys '{event_counters}_i_code_review_user_create_mr-*'
  6. Start the monitor again, but this time for the i_code_review_user_create_mr event rails runner scripts/internal_events/monitor.rb i_code_review_user_create_mr
  7. Verify that the metric values are the same as before and that the Instrumentation Class is now TotalCountMetric for redis_hll_counters.code_review.i_code_review_create_mr_weekly and redis_hll_counters.code_review.i_code_review_create_mr_monthly.

MR acceptance checklist

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

Related to #425302 (closed)

Edited by Jonas Larsen

Merge request reports