Class: GitlabInternalEventsCli::Subflows::DatabaseMetricDefiner

Inherits:
Object
  • Object
show all
Includes:
Helpers, Text::MetricDefiner
Defined in:
lib/gitlab_internal_events_cli/subflows/database_metric_definer.rb

Constant Summary collapse

CLASS_NAME_REGEX =
/\A[a-zA-Z]+\z/
DATABASE_OPERATIONS =

Maps each allowed database operation to its menu description. Mirrors the operations accepted by upstream ‘rails generate gitlab:usage_metric –type database`.

{
  'count' => 'count rows in the relation',
  'distinct_count' => 'count distinct values in a column',
  'estimate_batch_distinct_count' => 'approximate distinct count using HyperLogLog',
  'sum' => 'sum a numeric column',
  'average' => 'average a numeric column'
}.freeze
OPERATION_NAME_WIDTH =

Width used to align operation names with their descriptions in the menu.

DATABASE_OPERATIONS.keys.map(&:length).max

Constants included from Text::MetricDefiner

Text::MetricDefiner::ALL_METRICS_EXIST_NOTICE, Text::MetricDefiner::DATABASE_INSTRUMENTATION_FILES_NEXT_STEPS, Text::MetricDefiner::DATABASE_METRIC_DESCRIPTION_INTRO, Text::MetricDefiner::DATABASE_METRIC_NAME_HELP, Text::MetricDefiner::DESCRIPTION_HELP, Text::MetricDefiner::EVENT_METRIC_DESCRIPTION_INTRO, Text::MetricDefiner::INSTRUMENTATION_CLASS_ERROR, Text::MetricDefiner::INSTRUMENTATION_CLASS_HELP, Text::MetricDefiner::INSTRUMENTATION_CLASS_INTRO, Text::MetricDefiner::NAME_CONFLICT_HELP, Text::MetricDefiner::NAME_ERROR, Text::MetricDefiner::NAME_FILTER_HELP, Text::MetricDefiner::NAME_LENGTH_HELP, Text::MetricDefiner::NAME_REQUIREMENT_REASONS, Text::MetricDefiner::OPERATION_INTRO

Constants included from Helpers::Formatting

Helpers::Formatting::DEFAULT_WINDOW_HEIGHT, Helpers::Formatting::DEFAULT_WINDOW_WIDTH

Constants included from Helpers

Helpers::NAME_REGEX

Constants included from Helpers::Files

Helpers::Files::MAX_FILENAME_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Formatting

#clear_format, #counter, #divider, #format_error, #format_heading, #format_help, #format_info, #format_prefix, #format_prompt, #format_selection, #format_subheader, #format_warning, #progress_bar

Methods included from Helpers

#feedback_notice, #milestone, #new_page!

Methods included from Helpers::ServicePingDashboards

#metric_exploration_group_path, #metric_trend_path

Methods included from Helpers::MetricOptions

#get_metric_options

Methods included from Helpers::EventOptions

#events_by_filepath, #generate_ai_event_suggestion, #generate_python_advice, #get_event_options

Methods included from Helpers::GroupOwnership

#find_categories, #find_section, #find_stage, #known_categories, #prompt_for_feature_categories, #prompt_for_group_ownership

Methods included from Helpers::Files

#absolute_path, #file_saved_message, #prompt_to_save_file, #write_to_file

Methods included from Helpers::CliInputs

#disableable_option, #disabled_format_callback, #filter_opts, #format_disabled_options_as_dividers, #input_optional_text, #input_opts, #input_required_text, #multiselect_opts, #prompt_for_array_selection, #prompt_for_text, #select_option_divider, #select_opts, #yes_no_opts

Constructor Details

#initialize(cli) ⇒ DatabaseMetricDefiner

Returns a new instance of DatabaseMetricDefiner.



27
28
29
30
# File 'lib/gitlab_internal_events_cli/subflows/database_metric_definer.rb', line 27

def initialize(cli)
  @cli = cli
  @metric = nil
end

Instance Attribute Details

#metricObject (readonly)

Returns the value of attribute metric.



25
26
27
# File 'lib/gitlab_internal_events_cli/subflows/database_metric_definer.rb', line 25

def metric
  @metric
end

Instance Method Details

#runObject



32
33
34
35
36
37
38
39
# File 'lib/gitlab_internal_events_cli/subflows/database_metric_definer.rb', line 32

def run
  @metric = Metric.new
  metric.data_source = 'database'

  prompt_for_instrumentation_class
  prompt_for_operation
  prompt_for_time_frame
end