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
da19ce62
Commit
da19ce62
authored
Dec 12, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expire feature flag cache after 1minute
parent
fd0a5168
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+1
-1
spec/lib/gitlab/metrics/method_call_spec.rb
spec/lib/gitlab/metrics/method_call_spec.rb
+3
-5
No files found.
lib/gitlab/metrics/method_call.rb
View file @
da19ce62
...
...
@@ -80,7 +80,7 @@ module Gitlab
def
call_measurement_enabled?
expires_at
=
@@measurement_enabled_cache_expires_at
.
value
if
expires_at
<
Time
.
now
.
to_i
if
@@measurement_enabled_cache_expires_at
.
compare_and_set
(
expires_at
,
(
Time
.
now
+
30
.
seconds
)
.
to_i
)
if
@@measurement_enabled_cache_expires_at
.
compare_and_set
(
expires_at
,
1
.
minute
.
from_now
.
to_i
)
@@measurement_enabled_cache
.
value
=
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enabled?
end
end
...
...
spec/lib/gitlab/metrics/method_call_spec.rb
View file @
da19ce62
...
...
@@ -40,15 +40,13 @@ describe Gitlab::Metrics::MethodCall do
end
it
'expires feature check cache after 30 seconds'
do
10
.
times
do
method_call
.
measure
{
'foo'
}
end
Timecop
.
travel
(
Time
.
now
+
30
.
seconds
)
do
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
method_call
.
measure
{
'foo'
}
end
Timecop
.
travel
(
Time
.
now
+
31
.
seconds
)
do
Timecop
.
travel
(
1
.
minute
.
from_now
+
1
.
second
)
do
method_call
.
measure
{
'foo'
}
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