Skip to content

Remove collect_package_events feature flag with relevant code

Context

The MR added the feature flag :collect_package_events disabled by default to stop doing tracking of package events using the database, since the data was growing too fast and this solution was abandoned in favor of a redis solution.

What does this MR do and why?

This MR removes :collect_package_events feature flag and the related code it gates.

Additionally, since the packages_events table can be dropped, I moved out Packages::Event class from models to lib since it's still in use and provides a several methods and constants in a few places.

🔬 How to set up and validate locally

There is not much we can validate here, but what we still can do is to trigger the Packages::CreateEventService that uses several methods from Packages::Event and make sure it operates correctly after the code removal.

Perform the following steps in rails console:

  1. Trigger the service to create a new package event:

    Packages::CreateEventService.new(nil, User.first, event_name: :push_package, scope: :npm).execute
  2. Check that a new event was counted in redis:

    Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: 'i_package_npm_user', start_date: Date.current.beginning_of_week, end_date: Date.current.next_week)

Additionally we can execute the rake task that uses Packages::Event and check if the content of the files, that this task generates, contain information about package events.

  1. Execute the rake task

    $ rake gitlab:packages:events:generate
  2. Check the generated files that they contain information about the package events:

    $ less lib/gitlab/usage_data_counters/counter_events/package_events.yml
    $ less lib/gitlab/usage_data_counters/known_events/package_events.yml

    Note: the content of the files might slightly differ from what it was before. I believe that there is nothing wrong here, it only shows that the files haven't been updated recently.

🏁 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 #333827 (closed)

Edited by Dzmitry Meshcharakou

Merge request reports