summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 00:08:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-09 00:08:55 +0000
commit9ca5333a1227444383b8e01bf0cb173679e65627 (patch)
tree62219df6f97715c8094a63c8da87c7e703c8920c /lib
parent7db94a9807df03ce7a4f210b513816a47f34e15b (diff)
downloadgitlab-ce-9ca5333a1227444383b8e01bf0cb173679e65627.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/usage_data_counters/hll_redis_counter.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/gitlab/usage_data_counters/hll_redis_counter.rb b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
index 4b7ec45bcca..7ddd496cd85 100644
--- a/lib/gitlab/usage_data_counters/hll_redis_counter.rb
+++ b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
@@ -24,7 +24,7 @@ module Gitlab
# Event example:
#
# - name: g_compliance_dashboard # Unique event name
- # aggregation: daily # Aggregation level, keys are stored daily or weekly
+ # aggregation: weekly # Aggregation level, keys are stored weekly
#
# Usage:
#
@@ -94,7 +94,13 @@ module Gitlab
return if event.blank?
return unless Feature.enabled?(:redis_hll_tracking, type: :ops)
+ if event[:aggregation].to_sym == :daily
+ weekly_event = event.dup.tap { |e| e['aggregation'] = 'weekly' }
+ Gitlab::Redis::HLL.add(key: redis_key(weekly_event, time, context), value: values, expiry: expiry(weekly_event))
+ end
+
Gitlab::Redis::HLL.add(key: redis_key(event, time, context), value: values, expiry: expiry(event))
+
rescue StandardError => e
# Ignore any exceptions unless is dev or test env
# The application flow should not be blocked by erros in tracking
@@ -113,6 +119,11 @@ module Gitlab
aggregation = events.first[:aggregation]
+ if Feature.disabled?(:revert_daily_hll_events_to_weekly_aggregation)
+ aggregation = :weekly
+ events.each { |e| e[:aggregation] = :weekly }
+ end
+
keys = keys_for_aggregation(aggregation, events: events, start_date: start_date, end_date: end_date, context: context)
return FALLBACK unless keys.any?
@@ -162,6 +173,8 @@ module Gitlab
# Compose the key in order to store events daily or weekly
def redis_key(event, time, context = '')
raise UnknownEvent, "Unknown event #{event[:name]}" unless known_events_names.include?(event[:name].to_s)
+
+ # ToDo: remove during https://gitlab.com/groups/gitlab-org/-/epics/9542 cleanup
raise UnknownAggregation, "Use :daily or :weekly aggregation" unless ALLOWED_AGGREGATIONS.include?(event[:aggregation].to_sym)
key = "{#{REDIS_SLOT}}_#{event[:name]}"