diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /lib/tasks/gitlab/packages/events.rake | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/packages/events.rake')
-rw-r--r-- | lib/tasks/gitlab/packages/events.rake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/packages/events.rake b/lib/tasks/gitlab/packages/events.rake new file mode 100644 index 00000000000..3484b9b6072 --- /dev/null +++ b/lib/tasks/gitlab/packages/events.rake @@ -0,0 +1,40 @@ +require 'logger' + +desc "GitLab | Packages | Events | Generate hll counter events file for packages" +namespace :gitlab do + namespace :packages do + namespace :events do + task generate: :environment do + logger = Logger.new(STDOUT) + logger.info('Building list of package events...') + + path = File.join(File.dirname(::Gitlab::UsageDataCounters::HLLRedisCounter::KNOWN_EVENTS_PATH), 'package_events.yml') + + File.open(path, "w") { |file| file << generate_unique_events_list.to_yaml } + + logger.info("Events file `#{path}` generated successfully") + rescue => e + logger.error("Error building events list: #{e}") + end + + def event_pairs + ::Packages::Event.event_types.keys.product(::Packages::Event.originator_types.keys) + end + + def generate_unique_events_list + ::Packages::Event::EVENT_SCOPES.keys.each_with_object([]) do |event_scope, events| + event_pairs.each do |event_type, originator| + if name = ::Packages::Event.allowed_event_name(event_scope, event_type, originator) + events << { + "name" => name, + "category" => "#{event_scope}_packages", + "aggregation" => "weekly", + "redis_slot" => "package" + } + end + end + end + end + end + end +end |