diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /lib/gitlab/usage_data_counters | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'lib/gitlab/usage_data_counters')
-rw-r--r-- | lib/gitlab/usage_data_counters/base_counter.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/usage_data_counters/designs_counter.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/usage_data_counters/search_counter.rb | 24 |
3 files changed, 14 insertions, 18 deletions
diff --git a/lib/gitlab/usage_data_counters/base_counter.rb b/lib/gitlab/usage_data_counters/base_counter.rb index 96898e5189c..44893645cc2 100644 --- a/lib/gitlab/usage_data_counters/base_counter.rb +++ b/lib/gitlab/usage_data_counters/base_counter.rb @@ -8,7 +8,7 @@ module Gitlab::UsageDataCounters class << self def redis_key(event) - Gitlab::ErrorTracking.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s) + require_known_event(event) "USAGE_#{prefix}_#{event}".upcase end @@ -31,6 +31,10 @@ module Gitlab::UsageDataCounters private + def require_known_event(event) + Gitlab::ErrorTracking.track_and_raise_for_dev_exception(UnknownEvent.new, event: event) unless known_events.include?(event.to_s) + end + def counter_key(event) "#{prefix}_#{event}".to_sym end diff --git a/lib/gitlab/usage_data_counters/designs_counter.rb b/lib/gitlab/usage_data_counters/designs_counter.rb index 801fb8f3b3d..22188b555d2 100644 --- a/lib/gitlab/usage_data_counters/designs_counter.rb +++ b/lib/gitlab/usage_data_counters/designs_counter.rb @@ -4,7 +4,7 @@ module Gitlab::UsageDataCounters class DesignsCounter extend Gitlab::UsageDataCounters::RedisCounter - KNOWN_EVENTS = %w[create update delete].map(&:freeze).freeze + KNOWN_EVENTS = %w[create update delete].freeze UnknownEvent = Class.new(StandardError) diff --git a/lib/gitlab/usage_data_counters/search_counter.rb b/lib/gitlab/usage_data_counters/search_counter.rb index b9e3a5c0104..61f98887adc 100644 --- a/lib/gitlab/usage_data_counters/search_counter.rb +++ b/lib/gitlab/usage_data_counters/search_counter.rb @@ -2,28 +2,20 @@ module Gitlab module UsageDataCounters - class SearchCounter - extend RedisCounter - - NAVBAR_SEARCHES_COUNT_KEY = 'NAVBAR_SEARCHES_COUNT' + class SearchCounter < BaseCounter + KNOWN_EVENTS = %w[all_searches navbar_searches].freeze class << self - def increment_navbar_searches_count - increment(NAVBAR_SEARCHES_COUNT_KEY) - end + def redis_key(event) + require_known_event(event) - def total_navbar_searches_count - total_count(NAVBAR_SEARCHES_COUNT_KEY) + "#{event}_COUNT".upcase end - def totals - { - navbar_searches: total_navbar_searches_count - } - end + private - def fallback_totals - { navbar_searches: -1 } + def counter_key(event) + "#{event}".to_sym end end end |