diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /lib/generators | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'lib/generators')
-rw-r--r-- | lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb | 26 | ||||
-rw-r--r-- | lib/generators/gitlab/usage_metric_definition_generator.rb | 11 |
2 files changed, 33 insertions, 4 deletions
diff --git a/lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb b/lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb new file mode 100644 index 00000000000..d826c51a73d --- /dev/null +++ b/lib/generators/gitlab/usage_metric_definition/redis_hll_generator.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'rails/generators' +require_relative '../usage_metric_definition_generator' + +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" + + def create_metrics + Gitlab::UsageMetricDefinitionGenerator.start(["#{key_path}_weekly", '--dir', '7d']) + Gitlab::UsageMetricDefinitionGenerator.start(["#{key_path}_monthly", '--dir', '28d']) + end + + private + + def key_path + "redis_hll_counters.#{category}.#{event}" + end + end + end +end diff --git a/lib/generators/gitlab/usage_metric_definition_generator.rb b/lib/generators/gitlab/usage_metric_definition_generator.rb index 7a01050ed0c..cadc319a212 100644 --- a/lib/generators/gitlab/usage_metric_definition_generator.rb +++ b/lib/generators/gitlab/usage_metric_definition_generator.rb @@ -5,6 +5,11 @@ require 'rails/generators' module Gitlab class UsageMetricDefinitionGenerator < Rails::Generators::Base Directory = Struct.new(:name, :time_frame, :value_type) do + def initialize(...) + super + freeze + end + def match?(str) (name == str || time_frame == str) && str != 'none' end @@ -60,9 +65,7 @@ module Gitlab private def metric_name_suggestion - return unless Feature.enabled?(:product_intelligence_metrics_names_suggestions, default_enabled: :yaml) - - "\nname: #{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}" + "\nname: \"#{Usage::Metrics::NamesSuggestions::Generator.generate(key_path)}\"" end def file_path @@ -101,7 +104,7 @@ module Gitlab end def metric_definitions - @definitions ||= Gitlab::Usage::MetricDefinition.definitions + @definitions ||= Gitlab::Usage::MetricDefinition.definitions(skip_validation: true) end def metric_definition_exists? |