debian-mirror-gitlab/lib/gitlab/usage/metrics/names_suggestions/generator.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.9 KiB
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module NamesSuggestions
class Generator < ::Gitlab::UsageData
class << self
def generate(key_path)
2022-04-04 11:22:00 +05:30
data.deep_stringify_keys.dig(*key_path.split('.'))
2021-04-17 20:07:23 +05:30
end
2021-12-11 22:18:48 +05:30
def add_metric(metric, time_frame: 'none', options: {})
2021-10-27 15:23:28 +05:30
metric_class = "Gitlab::Usage::Metrics::Instrumentations::#{metric}".constantize
2021-12-11 22:18:48 +05:30
metric_class.new(time_frame: time_frame, options: options).suggested_name
2021-10-27 15:23:28 +05:30
end
2021-04-17 20:07:23 +05:30
private
def count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def distinct_count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:distinct_count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def redis_usage_counter
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:redis)
2021-04-17 20:07:23 +05:30
end
def alt_usage_data(*)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:alt)
2021-04-17 20:07:23 +05:30
end
def redis_usage_data_totals(counter)
2021-09-04 01:27:46 +05:30
counter.fallback_totals.transform_values { |_| Gitlab::Usage::Metrics::NameSuggestion.for(:redis) }
2021-04-17 20:07:23 +05:30
end
def sum(relation, column, *rest)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:sum, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def estimate_batch_distinct_count(relation, column = nil, *rest)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:estimate_batch_distinct_count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def add(*args)
"add_#{args.join('_and_')}"
end
end
end
end
end
end
end