Class: Gitlab::UsageDataCounters::BaseCounter
- Inherits:
-
Object
- Object
- Gitlab::UsageDataCounters::BaseCounter
show all
- Extended by:
- RedisCounter
- Defined in:
- lib/gitlab/usage_data_counters/base_counter.rb
Direct Known Subclasses
ContainerRegistryEventCounter, CycleAnalyticsCounter, DesignsCounter, DiffsCounter, KubernetesAgentCounter, MergeRequestCounter, MergeRequestWidgetExtensionCounter, NoteCounter, PackageEventCounter, ProductivityAnalyticsCounter, SearchCounter, ServiceUsageDataCounter, SnippetCounter, SourceCodeCounter, WebIdeCounter, WikiPageCounter
Constant Summary
collapse
- UnknownEvent =
Class.new(StandardError)
Class Method Summary
collapse
increment, increment_by, total_count
Class Method Details
.count(event) ⇒ Object
18
19
20
|
# File 'lib/gitlab/usage_data_counters/base_counter.rb', line 18
def count(event)
increment(redis_key(event))
end
|
.fallback_totals ⇒ Object
30
31
32
|
# File 'lib/gitlab/usage_data_counters/base_counter.rb', line 30
def fallback_totals
known_events.to_h { |event| [counter_key(event), -1] }
end
|
.fetch_supported_event(event_name) ⇒ Object
34
35
36
37
38
|
# File 'lib/gitlab/usage_data_counters/base_counter.rb', line 34
def fetch_supported_event(event_name)
return if prefix.present? && !event_name.start_with?(prefix)
known_events.find { |event| counter_key(event) == event_name.to_sym }
end
|
.read(event) ⇒ Object
22
23
24
|
# File 'lib/gitlab/usage_data_counters/base_counter.rb', line 22
def read(event)
total_count(redis_key(event))
end
|
.redis_key(event) ⇒ Object
.totals ⇒ Object
26
27
28
|
# File 'lib/gitlab/usage_data_counters/base_counter.rb', line 26
def totals
known_events.to_h { |event| [counter_key(event), read(event)] }
end
|