diff options
Diffstat (limited to 'lib/gitlab/usage')
-rw-r--r-- | lib/gitlab/usage/metric.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/usage/metrics/names_suggestions/generator.rb | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab/usage/metric.rb b/lib/gitlab/usage/metric.rb index 5b1ac189c13..24e044c5740 100644 --- a/lib/gitlab/usage/metric.rb +++ b/lib/gitlab/usage/metric.rb @@ -25,6 +25,10 @@ module Gitlab unflatten_key_path(intrumentation_object.instrumentation) end + def with_suggested_name + unflatten_key_path(intrumentation_object.suggested_name) + end + private def unflatten_key_path(value) diff --git a/lib/gitlab/usage/metrics/names_suggestions/generator.rb b/lib/gitlab/usage/metrics/names_suggestions/generator.rb index b47dc5689d4..6dcbe5f5fe5 100644 --- a/lib/gitlab/usage/metrics/names_suggestions/generator.rb +++ b/lib/gitlab/usage/metrics/names_suggestions/generator.rb @@ -10,14 +10,18 @@ module Gitlab uncached_data.deep_stringify_keys.dig(*key_path.split('.')) end - def add_metric(metric, time_frame: 'none') + def add_metric(metric, time_frame: 'none', options: {}) metric_class = "Gitlab::Usage::Metrics::Instrumentations::#{metric}".constantize - metric_class.new(time_frame: time_frame).suggested_name + metric_class.new(time_frame: time_frame, options: options).suggested_name end private + def instrumentation_metrics + ::Gitlab::UsageDataMetrics.suggested_names + end + def count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil) Gitlab::Usage::Metrics::NameSuggestion.for(:count, column: column, relation: relation) end |