Skip to content

Move WebIdeCounter to metrics definitions

Michał Wielich requested to merge refactor-redis-counters-v4 into master

What does this MR do and why?

Related to #339445 (closed)

We want to move metrics-related code from our chunky UsageData class into a system of yml files including metrics definitions.

Screenshots or screen recordings

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

How to set up and validate locally

This test should make sure that we didn't miss any metrics [eg, it is failing after removing the instrumentation_class: clause from any of the yml files].

To test that the actual values for events are also counted correctly:

  1. Checkout master branch
  2. Trigger some events related to the migrated metrics, for example:
  • open Web IDE [project -> repository -> select a file -> open in Web IDE]
  • create a commit with Web IDE
  • create an MR with Web IDE
  • open the pipelines panel in Web IDE [it's on the right side]
  • open the web terminal in Web IDE [it's on the right side]
  • use Web IDE's live preview
  1. Run this in the console:
counter_classes = [
  Gitlab::UsageDataCounters::WebIdeCounter,
]
raw_events = counter_classes.map {|cc| [cc, cc::KNOWN_EVENTS]}
events = raw_events.map do |cc, evs|
  evs.map { |ev| "#{cc::PREFIX}_#{ev}" }
end.flatten
service_ping = Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)

values1 = service_ping[:counts].values_at(*events)
  • This will save the event statistics under the values1 variable. The values1 array should include some non-zero values if the events have been successfully triggered. Now what we will need to do is compare it with the result we get with this MR:
  1. Check out this MR's branch
  2. Run this in the console:
reload!
service_ping = Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
values2 = service_ping[:counts].values_at(*events)
  1. Now, the values1 and values2 should have the same value. This will prove that the events have been added to Service Ping data correctly.
values2 == values1
=> true

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