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:
- Change the metric definitions to use the
i_code_review_user_create_mr
event instead ofi_code_review_create_mr
.i_code_review_user_create_mr
already has an event definition and we only need one event now. - Removes usage of
i_code_review_create_mr
- 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
- Checkout
master
- Run the monitor
rails runner scripts/internal_events/monitor.rb i_code_review_create_mr
and note down the values for the two RedisHLLMetrics. - Checkout the new branch
- Run the migrations
bundle exec rake db:migrate
- Verify that the new keys are created `gdk redis-cli keys '{event_counters}_i_code_review_user_create_mr-*'
- Start the monitor again, but this time for the
i_code_review_user_create_mr
eventrails runner scripts/internal_events/monitor.rb i_code_review_user_create_mr
- Verify that the metric values are the same as before and that the Instrumentation Class is now
TotalCountMetric
forredis_hll_counters.code_review.i_code_review_create_mr_weekly
andredis_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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #425302 (closed)