Class: Gitlab::Usage::Metrics::Instrumentations::BaseMetric
- Inherits:
-
Object
- Object
- Gitlab::Usage::Metrics::Instrumentations::BaseMetric
- Includes:
- TimeFrame, Gitlab::Utils::UsageData
- Defined in:
- lib/gitlab/usage/metrics/instrumentations/base_metric.rb
Direct Known Subclasses
AggregatedMetric, DatabaseMetric, GenericMetric, NumbersMetric, RedisHLLMetric, RedisMetric, TotalCountMetric
Constant Summary
Constants included from TimeFrame
TimeFrame::ALL_TIME_TIME_FRAME_NAME, TimeFrame::DEFAULT_TIMESTAMP_COLUMN, 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
-
.metric_available ⇒ Object
readonly
Returns the value of attribute metric_available.
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#time_frame ⇒ Object
readonly
Returns the value of attribute time_frame.
Class Method Summary collapse
Instance Method Summary collapse
- #available? ⇒ Boolean
-
#initialize(metric_definition) ⇒ BaseMetric
constructor
A new instance of BaseMetric.
- #instrumentation ⇒ Object
Methods included from TimeFrame
#monthly_time_range, #monthly_time_range_db_params, #weekly_time_range, #weekly_time_range_db_params
Methods included from Gitlab::Utils::UsageData
#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Constructor Details
#initialize(metric_definition) ⇒ BaseMetric
Returns a new instance of BaseMetric.
27 28 29 30 31 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 27 def initialize(metric_definition) @time_frame = metric_definition.fetch(:time_frame) @options = metric_definition.fetch(:options, {}) @events = metric_definition.fetch(:events, {}) end |
Class Attribute Details
.metric_available ⇒ Object (readonly)
Returns the value of attribute metric_available.
24 25 26 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 24 def metric_available @metric_available end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
13 14 15 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 13 def events @events end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 12 def @options end |
#time_frame ⇒ Object (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
16 17 18 19 20 21 22 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 16 def available?(&block) return @metric_available = block if block return @metric_available.call if instance_variable_defined?(:@metric_available) true end |
Instance Method Details
#available? ⇒ Boolean
37 38 39 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 37 def available? self.class.available? end |
#instrumentation ⇒ Object
33 34 35 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 33 def instrumentation value end |