2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
class UsageDataNonSqlMetrics < UsageData
|
|
|
|
SQL_METRIC_DEFAULT = -3
|
|
|
|
|
|
|
|
class << self
|
2021-10-27 15:23:28 +05:30
|
|
|
def uncached_data
|
2021-12-11 22:18:48 +05:30
|
|
|
# instrumentation_metrics is already included with feature flag enabled
|
|
|
|
return super if Feature.enabled?(:usage_data_instrumentation)
|
|
|
|
|
|
|
|
super.with_indifferent_access.deep_merge(instrumentation_metrics.with_indifferent_access)
|
2021-10-27 15:23:28 +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).instrumentation
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
def count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
|
|
|
|
SQL_METRIC_DEFAULT
|
|
|
|
end
|
|
|
|
|
|
|
|
def distinct_count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
|
|
|
|
SQL_METRIC_DEFAULT
|
|
|
|
end
|
|
|
|
|
|
|
|
def estimate_batch_distinct_count(relation, column = nil, batch_size: nil, start: nil, finish: nil)
|
|
|
|
SQL_METRIC_DEFAULT
|
|
|
|
end
|
|
|
|
|
|
|
|
def sum(relation, column, batch_size: nil, start: nil, finish: nil)
|
|
|
|
SQL_METRIC_DEFAULT
|
|
|
|
end
|
|
|
|
|
|
|
|
def histogram(relation, column, buckets:, bucket_size: buckets.size)
|
|
|
|
SQL_METRIC_DEFAULT
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def maximum_id(model, column = nil)
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def minimum_id(model, column = nil)
|
|
|
|
end
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
def jira_integration_data
|
2021-06-08 01:23:25 +05:30
|
|
|
{
|
|
|
|
projects_jira_server_active: 0,
|
|
|
|
projects_jira_cloud_active: 0
|
|
|
|
}
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
def instrumentation_metrics
|
2021-10-27 15:23:28 +05:30
|
|
|
::Gitlab::Usage::Metric.all.map(&:with_instrumentation).reduce({}, :deep_merge)
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|