2021-06-08 01:23:25 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Usage
|
|
|
|
module Metrics
|
|
|
|
module Instrumentations
|
|
|
|
class BaseMetric
|
|
|
|
include Gitlab::Utils::UsageData
|
2021-09-04 01:27:46 +05:30
|
|
|
include Gitlab::Usage::TimeFrame
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
attr_reader :time_frame
|
2021-09-04 01:27:46 +05:30
|
|
|
attr_reader :options
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
class << self
|
|
|
|
def available?(&block)
|
2022-08-27 11:52:29 +05:30
|
|
|
return @metric_available = block if block
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
return @metric_available.call if instance_variable_defined?(:@metric_available)
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :metric_available
|
|
|
|
end
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
def initialize(metric_definition)
|
|
|
|
@time_frame = metric_definition.fetch(:time_frame)
|
|
|
|
@options = metric_definition.fetch(:options, {})
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
|
|
|
def instrumentation
|
|
|
|
value
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
def available?
|
|
|
|
self.class.available?
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|