blob: e343e2dcf91fe834cb6b4a2a8428572e230c9df6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
require 'rails/generators'
module Gitlab
module UsageMetricDefinition
class RedisHllGenerator < Rails::Generators::Base
desc 'Generates a metric definition .yml file with defaults for Redis HLL.'
argument :category, type: :string, desc: "Category name"
argument :event, type: :string, desc: "Event name"
class_option :ee, type: :boolean, optional: true, default: false, desc: 'Indicates if metric is for ee'
def create_metrics
weekly_params = ["#{key_path}_weekly", '--dir', '7d']
weekly_params << '--ee' if ee?
Gitlab::UsageMetricDefinitionGenerator.start(weekly_params)
monthly_params = ["#{key_path}_monthly", '--dir', '28d']
monthly_params << '--ee' if ee?
Gitlab::UsageMetricDefinitionGenerator.start(monthly_params)
end
private
def ee?
options[:ee]
end
def key_path
"redis_hll_counters.#{category}.#{event}"
end
end
end
end
|