Module: Gitlab::UsageDataCounters::HLLRedisCounter

Extended by:
Gitlab::Usage::TimeFrame, Gitlab::Usage::TimeSeriesStorable, Gitlab::Utils::UsageData
Defined in:
lib/gitlab/usage_data_counters/hll_redis_counter.rb

Constant Summary collapse

KEY_EXPIRY_LENGTH =
6.weeks
REDIS_SLOT =
'hll_counters'
EventError =
Class.new(StandardError)
UnknownEvent =
Class.new(EventError)

Constants included from Gitlab::Usage::TimeFrame

Gitlab::Usage::TimeFrame::ALL_TIME_TIME_FRAME_NAME, Gitlab::Usage::TimeFrame::DEFAULT_TIMESTAMP_COLUMN, Gitlab::Usage::TimeFrame::SEVEN_DAYS_TIME_FRAME_NAME, Gitlab::Usage::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 Method Summary collapse

Methods included from Gitlab::Usage::TimeSeriesStorable

apply_time_aggregation, keys_for_aggregation

Methods included from Gitlab::Usage::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

Class Method Details

.calculate_events_union(event_names:, start_date:, end_date:) ⇒ Object



49
50
51
# File 'lib/gitlab/usage_data_counters/hll_redis_counter.rb', line 49

def calculate_events_union(event_names:, start_date:, end_date:)
  count_unique_events(event_names: event_names, start_date: start_date, end_date: end_date)
end

.known_event?(event_name) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/gitlab/usage_data_counters/hll_redis_counter.rb', line 41

def known_event?(event_name)
  event_for(event_name).present?
end

.known_eventsObject



45
46
47
# File 'lib/gitlab/usage_data_counters/hll_redis_counter.rb', line 45

def known_events
  @known_events ||= load_events
end

.track_event(event_name, values:, time: Time.current) ⇒ Object

Track unique events

event_name - The event name. values - One or multiple values counted. time - Time of the action, set to Time.current.



28
29
30
# File 'lib/gitlab/usage_data_counters/hll_redis_counter.rb', line 28

def track_event(event_name, values:, time: Time.current)
  track(values, event_name, time: time)
end

.unique_events(event_names:, start_date:, end_date:) ⇒ Object

Count unique events for a given time range.

event_names - The list of the events to count. start_date - The start date of the time range. end_date - The end date of the time range.



37
38
39
# File 'lib/gitlab/usage_data_counters/hll_redis_counter.rb', line 37

def unique_events(event_names:, start_date:, end_date:)
  count_unique_events(event_names: event_names, start_date: start_date, end_date: end_date)
end