debian-mirror-gitlab/lib/gitlab/usage/metrics/instrumentations/base_metric.rb

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

43 lines
902 B
Ruby
Raw Normal View History

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
return @metric_available.call if instance_variable_defined?('@metric_available')
true
end
attr_reader :metric_available
end
2021-09-04 01:27:46 +05:30
def initialize(time_frame:, options: {})
2021-06-08 01:23:25 +05:30
@time_frame = time_frame
2021-09-04 01:27:46 +05:30
@options = 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