Class: Gitlab::Usage::Metrics::Instrumentations::BaseMetric

Inherits:
Object
  • Object
show all
Includes:
TimeFrame, Gitlab::Utils::UsageData
Defined in:
lib/gitlab/usage/metrics/instrumentations/base_metric.rb

Constant Summary

Constants included from TimeFrame

TimeFrame::ALL_TIME_TIME_FRAME_NAME, TimeFrame::SEVEN_DAYS_TIME_FRAME_NAME, TimeFrame::TWENTY_EIGHT_DAYS_TIME_FRAME_NAME

Constants included from Gitlab::Utils::UsageData

Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TimeFrame

#monthly_time_range, #monthly_time_range_db_params, #weekly_time_range

Methods included from Gitlab::Utils::UsageData

#add, #add_metric, #alt_usage_data, #count, #distinct_count, #epics_deepest_relationship_level, #estimate_batch_distinct_count, #histogram, #jira_integration_data, #maximum_id, #measure_duration, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_duration, #with_finished_at, #with_prometheus_client

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(time_frame:, options: {}) ⇒ BaseMetric

Returns a new instance of BaseMetric.


26
27
28
29
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 26

def initialize(time_frame:, options: {})
  @time_frame = time_frame
  @options = options
end

Class Attribute Details

.metric_availableObject (readonly)

Returns the value of attribute metric_available.


23
24
25
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 23

def metric_available
  @metric_available
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.


12
13
14
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 12

def options
  @options
end

#time_frameObject (readonly)

Returns the value of attribute time_frame.


11
12
13
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 11

def time_frame
  @time_frame
end

Class Method Details

.available?(&block) ⇒ Boolean

Returns:

  • (Boolean)

15
16
17
18
19
20
21
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 15

def available?(&block)
  return @metric_available = block if block_given?

  return @metric_available.call if instance_variable_defined?('@metric_available')

  true
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 35

def available?
  self.class.available?
end

#instrumentationObject


31
32
33
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 31

def instrumentation
  value
end