Skip to content

Use `events` over `options` for internal events

Michał Wielich requested to merge michold-internal-events-options into master

What does this MR do and why?

Related to #427298 (closed)

All internal events metrics currently repeat the same data in options and events attribute. As a first step towards removing options, let's make it so that the metrics classes read the events attribute instead of the options attribute when possible.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

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. Stay on master branch
  2. Choose an internal_events metric with events: key, for example: g_project_management_issue_removed_from_epic_monthly
  3. Trigger the event tracked by the metric for last week, for example: Gitlab::UsageDataCounters::HLLRedisCounter.track_event('g_project_management_issue_removed_from_epic', values: SecureRandom.uuid, property_name: 'user.id', time: 1.week.ago). You can repeat that multiple times.
  4. Open the rails console and try to calculate the chosen metric, for example: Gitlab::Usage::ServicePing::InstrumentedPayload.new(['redis_hll_counters.issues_edit.g_project_management_issue_removed_from_epic_monthly'], :with_value).build. Since we triggered the event, this should return a non-zero value.
  5. Checkout this MR's branch and reload! the console
  6. Calculate the metric again: Gitlab::Usage::ServicePing::InstrumentedPayload.new(['redis_hll_counters.issues_edit.g_project_management_issue_removed_from_epic_monthly'], :with_value).build
  7. This should return the same value as before.
  8. Remove the options block from the metric (example: lines 12-14) and reload! the console again
  9. Calculate the metric again. This should return the same value again.
Edited by Michał Wielich

Merge request reports