blob: 0f4b903b99cf6889a2d395e27a1d03dba626d22f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class GenericMetric < BaseMetric
# Usage example
#
# class UuidMetric < GenericMetric
# value do
# Gitlab::CurrentSettings.uuid
# end
# end
FALLBACK = -1
class << self
attr_reader :metric_value
def fallback(custom_fallback = FALLBACK)
return @metric_fallback if defined?(@metric_fallback)
@metric_fallback = custom_fallback
end
def value(&block)
@metric_value = block
end
end
def initialize(time_frame: 'none', options: {})
@time_frame = time_frame
@options = options
end
def value
alt_usage_data(fallback: self.class.fallback) do
self.class.metric_value.call
end
end
def suggested_name
Gitlab::Usage::Metrics::NameSuggestion.for(:alt)
end
end
end
end
end
end
|