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
61b6a561
Commit
61b6a561
authored
Aug 24, 2020
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix expiry time for redis hll counter
parent
881661c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
lib/gitlab/usage_data_counters/hll_redis_counter.rb
lib/gitlab/usage_data_counters/hll_redis_counter.rb
+1
-1
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+26
-0
No files found.
lib/gitlab/usage_data_counters/hll_redis_counter.rb
View file @
61b6a561
...
...
@@ -91,7 +91,7 @@ module Gitlab
end
def
expiry
(
event
)
return
event
[
:expiry
]
if
event
[
:expiry
].
present?
return
event
[
:expiry
]
.
days
if
event
[
:expiry
].
present?
event
[
:aggregation
].
to_sym
==
:daily
?
DEFAULT_DAILY_KEY_EXPIRY_LENGTH
:
DEFAULT_WEEKLY_KEY_EXPIRY_LENGTH
end
...
...
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
61b6a561
...
...
@@ -45,6 +45,32 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
it
'raise error if metrics of unknown aggregation'
do
expect
{
described_class
.
track_event
(
entity1
,
'unknown'
,
Date
.
current
)
}
.
to
raise_error
(
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
::
UnknownEvent
)
end
it
'sets the keys in Redis to expire automatically after 12 weeks'
do
described_class
.
track_event
(
entity1
,
"g_analytics_contribution"
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
keys
=
redis
.
scan_each
(
match:
"g_{analytics}_contribution-*"
).
to_a
expect
(
keys
).
not_to
be_empty
redis
.
scan_each
(
match:
"g_{analytics}_contribution-*"
).
each
do
|
key
|
expect
(
redis
.
ttl
(
key
)).
to
be_within
(
5
.
seconds
).
of
(
12
.
weeks
)
end
end
end
it
'sets the keys in Redis to expire automatically after 6 weeks by default'
do
described_class
.
track_event
(
entity1
,
"g_compliance_dashboard"
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
keys
=
redis
.
scan_each
(
match:
"g_{compliance}_dashboard-*"
).
to_a
expect
(
keys
).
not_to
be_empty
redis
.
scan_each
(
match:
"g_{compliance}_dashboard-*"
).
each
do
|
key
|
expect
(
redis
.
ttl
(
key
)).
to
be_within
(
5
.
seconds
).
of
(
6
.
weeks
)
end
end
end
end
describe
'.unique_events'
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