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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
351bc078
Commit
351bc078
authored
Jul 19, 2019
by
Francisco Javier López
Committed by
Nick Thomas
Jul 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid increasing redis counters when usage_ping is disabled
parent
2db1317b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
changelogs/unreleased/fj-avoid-incresaing-usage-ping-when-not-enabled.yml
...eased/fj-avoid-incresaing-usage-ping-when-not-enabled.yml
+5
-0
lib/gitlab/usage_data_counters/redis_counter.rb
lib/gitlab/usage_data_counters/redis_counter.rb
+2
-0
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
+33
-0
No files found.
changelogs/unreleased/fj-avoid-incresaing-usage-ping-when-not-enabled.yml
0 → 100644
View file @
351bc078
---
title
:
Avoid increasing redis counters when usage_ping is disabled
merge_request
:
30949
author
:
type
:
changed
lib/gitlab/usage_data_counters/redis_counter.rb
View file @
351bc078
...
...
@@ -4,6 +4,8 @@ module Gitlab
module
UsageDataCounters
module
RedisCounter
def
increment
(
redis_counter_key
)
return
unless
Gitlab
::
CurrentSettings
.
usage_ping_enabled
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
incr
(
redis_counter_key
)
}
end
...
...
spec/lib/gitlab/usage_data_counters/redis_counter_spec.rb
0 → 100644
View file @
351bc078
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
UsageDataCounters
::
RedisCounter
,
:clean_gitlab_redis_shared_state
do
let
(
:redis_key
)
{
'foobar'
}
subject
{
Class
.
new
.
extend
(
described_class
)
}
before
do
stub_application_setting
(
usage_ping_enabled:
setting_value
)
end
context
'when usage_ping is disabled'
do
let
(
:setting_value
)
{
false
}
it
'counter is not increased'
do
expect
do
subject
.
increment
(
redis_key
)
end
.
not_to
change
{
subject
.
total_count
(
redis_key
)
}
end
end
context
'when usage_ping is enabled'
do
let
(
:setting_value
)
{
true
}
it
'counter is increased'
do
expect
do
subject
.
increment
(
redis_key
)
end
.
to
change
{
subject
.
total_count
(
redis_key
)
}.
by
(
1
)
end
end
end
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