Class: Gitlab::Usage::Metrics::Instrumentations::AggregatedMetric
- Inherits:
-
BaseMetric
- Object
- BaseMetric
- Gitlab::Usage::Metrics::Instrumentations::AggregatedMetric
- Defined in:
- lib/gitlab/usage/metrics/instrumentations/aggregated_metric.rb
Overview
Usage example
In metric YAML definition:
instrumentation_class: AggregatedMetric data_source: redis_hll options:
aggregate:
operator: OR
attribute: user_id
events:
- 'incident_management_alert_status_changed'
- 'incident_management_alert_assigned'
- 'incident_management_alert_todo'
- 'incident_management_alert_create_incident'
Constant Summary collapse
- FALLBACK =
-1
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::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE
Instance Attribute Summary
Attributes inherited from BaseMetric
#events, #options, #time_frame
Instance Method Summary collapse
-
#initialize(metric_definition) ⇒ AggregatedMetric
constructor
A new instance of AggregatedMetric.
- #value ⇒ Object
Methods inherited from BaseMetric
available?, #available?, #instrumentation
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) ⇒ AggregatedMetric
Returns a new instance of AggregatedMetric.
26 27 28 29 30 |
# File 'lib/gitlab/usage/metrics/instrumentations/aggregated_metric.rb', line 26 def initialize(metric_definition) super @source = metric_definition[:data_source] @aggregate = .fetch(:aggregate, {}) end |
Instance Method Details
#value ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab/usage/metrics/instrumentations/aggregated_metric.rb', line 32 def value alt_usage_data(fallback: FALLBACK) do Aggregates::Aggregate .new(Time.current) .calculate_count_for_aggregation( aggregation: aggregate_config, time_frame: time_frame ) end end |