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
DatabaseMetric, GenericMetric, NumbersMetric, RedisHLLMetric, RedisMetric, TotalCountMetric, TotalSumMetric, UniqueCountMetric
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.
-
#metric_definition ⇒ Object
readonly
Returns the value of attribute metric_definition.
-
#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(attributes) ⇒ 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(attributes) ⇒ BaseMetric
Returns a new instance of BaseMetric.
28 29 30 31 32 33 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 28 def initialize(attributes) @metric_definition = MetricDefinition.new(nil, attributes) @time_frame = attributes.fetch(:time_frame) @options = attributes.fetch(:options, {}) @events = attributes.fetch(:events, {}) end |
Class Attribute Details
.metric_available ⇒ Object (readonly)
Returns the value of attribute metric_available.
25 26 27 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 25 def metric_available @metric_available end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
14 15 16 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 14 def events @events end |
#metric_definition ⇒ Object (readonly)
Returns the value of attribute metric_definition.
11 12 13 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 11 def metric_definition @metric_definition end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 13 def @options end |
#time_frame ⇒ Object (readonly)
Returns the value of attribute time_frame.
12 13 14 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 12 def time_frame @time_frame end |
Class Method Details
.available?(&block) ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 17 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
39 40 41 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 39 def available? self.class.available? end |
#instrumentation ⇒ Object
35 36 37 |
# File 'lib/gitlab/usage/metrics/instrumentations/base_metric.rb', line 35 def instrumentation value end |