Migrate package push metrics to internal events
What does this MR do and why?
Related to #424893 (closed)
Migrate package push events & metrics to InternalEvents framework.
This is the third MR addressing package events, after !151919 (merged) and !153159 (merged)
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
- On
master
branch, in the ruby console, trigger all the migrated events:%w[i_package_composer_push_package i_package_conan_push_package i_package_generic_push_package i_package_golang_push_package i_package_maven_push_package i_package_npm_push_package i_package_nuget_push_package i_package_pypi_push_package i_package_rubygems_push_package i_package_terraform_module_push_package i_package_helm_push_package i_package_rpm_push_package i_package_push_package i_package_push_package_by_deploy_token i_package_push_package_by_guest i_package_push_package_by_user].each {|ev| ::Gitlab::UsageDataCounters::PackageEventCounter.count(ev)}
- Calculate the metrics values:
metrics = %w[counts.package_events_i_package_composer_push_package counts.package_events_i_package_conan_push_package counts.package_events_i_package_generic_push_package counts.package_events_i_package_golang_push_package counts.package_events_i_package_maven_push_package counts.package_events_i_package_npm_push_package counts.package_events_i_package_nuget_push_package counts.package_events_i_package_push_package counts.package_events_i_package_push_package_by_deploy_token counts.package_events_i_package_push_package_by_guest counts.package_events_i_package_push_package_by_user counts.package_events_i_package_pypi_push_package counts.package_events_i_package_rubygems_push_package counts.package_events_i_package_terraform_module_push_package counts.package_events_i_package_helm_push_package counts.package_events_i_package_rpm_push_package]; sp = Gitlab::Usage::ServicePing::InstrumentedPayload.new(metrics, :with_value).build
- Check out this MR's branch and
reload!
the console - Make sure that all the metrics have the same values:
sp2 = Gitlab::Usage::ServicePing::InstrumentedPayload.new(metrics, :with_value).build
and then verify thatsp == sp2
returnstrue
- Trigger all of the events again:
%w[composer conan generic golang maven npm nuget pypi rubygems terraform_module helm rpm].each {|p| Gitlab::InternalEvents.track_event('push_package_to_registry', additional_properties: { label: p })}; %w[deploy_token guest user].each {|p| Gitlab::InternalEvents.track_event('push_package_to_registry', additional_properties: { property: p })}
- Generate new metric values
sp3 = Gitlab::Usage::ServicePing::InstrumentedPayload.new(metrics, :with_value).build
- Make sure that all the metrics values have increased:
sp3.values.first.map {|k, v| v > sp2[:counts][k]}.uniq
should return[true]
Edited by Michał Wielich