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
bc095759
Commit
bc095759
authored
Jul 15, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add license usage ping check to HLLRedisCounter
parent
7803c691
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
1 deletion
+52
-1
ee/lib/ee/gitlab/usage_data_counters/hll_redis_counter.rb
ee/lib/ee/gitlab/usage_data_counters/hll_redis_counter.rb
+5
-0
ee/spec/lib/ee/gitlab/usage_data_counters/hll_redis_counter_spec.rb
...b/ee/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+42
-0
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+5
-1
No files found.
ee/lib/ee/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
bc095759
...
...
@@ -12,6 +12,11 @@ module EE
def
valid_context_list
super
+
License
.
all_plans
end
override
:usage_ping_enabled?
def
usage_ping_enabled?
::
License
.
current
&
.
customer_service_enabled?
||
super
end
end
end
end
...
...
ee/spec/lib/ee/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
bc095759
...
...
@@ -96,4 +96,46 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
end
end
end
describe
'.track_event'
do
context
'with settings usage ping disabled'
do
before
do
stub_application_setting
(
usage_ping_enabled:
false
)
end
context
'with license usage ping disabled'
do
before
do
# License.current.customer_service_enabled? == true
create_current_license
(
operational_metrics_enabled:
false
)
end
it
'does not track the event'
do
expect
(
Gitlab
::
Redis
::
HLL
).
not_to
receive
(
:add
)
described_class
.
track_event
(
context_event
,
values:
entity1
,
time:
Date
.
current
)
end
end
context
'with license usage ping enabled'
do
before
do
# License.current.customer_service_enabled? == true
create_current_license
(
operational_metrics_enabled:
true
)
end
it
'tracks the event'
do
expect
(
Gitlab
::
Redis
::
HLL
).
to
receive
(
:add
)
described_class
.
track_event
(
context_event
,
values:
entity1
,
time:
Date
.
current
)
end
end
context
'without a license'
,
:without_license
do
it
'does not track the event'
do
expect
(
Gitlab
::
Redis
::
HLL
).
not_to
receive
(
:add
)
described_class
.
track_event
(
context_event
,
values:
entity1
,
time:
Date
.
current
)
end
end
end
end
end
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
bc095759
...
...
@@ -117,7 +117,7 @@ module Gitlab
private
def
track
(
values
,
event_name
,
context:
''
,
time:
Time
.
zone
.
now
)
return
unless
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
return
unless
usage_ping_enabled?
event
=
event_for
(
event_name
)
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
UnknownEvent
.
new
(
"Unknown event
#{
event_name
}
"
))
unless
event
.
present?
...
...
@@ -131,6 +131,10 @@ module Gitlab
Gitlab
::
ErrorTracking
.
track_and_raise_for_dev_exception
(
e
)
end
def
usage_ping_enabled?
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
end
# The array of valid context on which we allow tracking
def
valid_context_list
Plan
.
all_plans
...
...
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