Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b6cb0e6e
Commit
b6cb0e6e
authored
Sep 08, 2020
by
Alina Mihaila
Committed by
Sean McGivern
Sep 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for usage ping enabled when tracking using Redis HLL
parent
3c96d96d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
38 deletions
+61
-38
changelogs/unreleased/245247-check-for-usage-ping-enabled-when-tracking-using-redis-hll.yml
...-for-usage-ping-enabled-when-tracking-using-redis-hll.yml
+5
-0
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+2
-0
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+54
-38
No files found.
changelogs/unreleased/245247-check-for-usage-ping-enabled-when-tracking-using-redis-hll.yml
0 → 100644
View file @
b6cb0e6e
---
title
:
Check if usage ping enabled for all tracking using Redis HLL
merge_request
:
41562
author
:
type
:
added
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
b6cb0e6e
...
...
@@ -34,6 +34,8 @@ module Gitlab
# * Get unique counts per user: Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(event_names: 'g_compliance_dashboard', start_date: 28.days.ago, end_date: Date.current)
class
<<
self
def
track_event
(
entity_id
,
event_name
,
time
=
Time
.
zone
.
now
)
return
unless
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
event
=
event_for
(
event_name
)
raise
UnknownEvent
.
new
(
"Unknown event
#{
event_name
}
"
)
unless
event
.
present?
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
b6cb0e6e
...
...
@@ -62,6 +62,21 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
end
describe
'.track_event'
do
context
'when usage_ping is disabled'
do
it
'does not track the event'
do
stub_application_setting
(
usage_ping_enabled:
false
)
described_class
.
track_event
(
entity1
,
weekly_event
,
Date
.
current
)
expect
(
Gitlab
::
Redis
::
HLL
).
not_to
receive
(
:add
)
end
end
context
'when usage_ping is enabled'
do
before
do
stub_application_setting
(
usage_ping_enabled:
true
)
end
it
"raise error if metrics don't have same aggregation"
do
expect
{
described_class
.
track_event
(
entity1
,
different_aggregation
,
Date
.
current
)
}
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownAggregation
)
end
...
...
@@ -126,6 +141,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
end
end
end
end
describe
'.unique_events'
do
before
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment