BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
+3
-5
method_call.rb
lib/gitlab/metrics/method_call.rb
+1
-1
method_call_spec.rb
spec/lib/gitlab/metrics/method_call_spec.rb
+2
-4
No files found.
lib/gitlab/metrics/method_call.rb
View file @
da19ce62
...
@@ -80,7 +80,7 @@ module Gitlab
...
@@ -80,7 +80,7 @@ module Gitlab
def
call_measurement_enabled?
def
call_measurement_enabled?
expires_at
=
@@measurement_enabled_cache_expires_at
.
value
expires_at
=
@@measurement_enabled_cache_expires_at
.
value
if
expires_at
<
Time
.
now
.
to_i
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?
@@measurement_enabled_cache
.
value
=
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enabled?
end
end
end
end
...
...
spec/lib/gitlab/metrics/method_call_spec.rb
View file @
da19ce62
...
@@ -40,15 +40,13 @@ describe Gitlab::Metrics::MethodCall do
...
@@ -40,15 +40,13 @@ describe Gitlab::Metrics::MethodCall do
end
end
it
'expires feature check cache after 30 seconds'
do
it
'expires feature check cache after 30 seconds'
do
10
.
times
do
method_call
.
measure
{
'foo'
}
method_call
.
measure
{
'foo'
}
end
Timecop
.
travel
(
Time
.
now
+
30
.
seconds
)
do
Timecop
.
travel
(
1
.
minute
.
from_now
)
do
method_call
.
measure
{
'foo'
}
method_call
.
measure
{
'foo'
}
end
end
Timecop
.
travel
(
Time
.
now
+
31
.
seconds
)
do
Timecop
.
travel
(
1
.
minute
.
from_now
+
1
.
second
)
do
method_call
.
measure
{
'foo'
}
method_call
.
measure
{
'foo'
}
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