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
53dc9e83
Commit
53dc9e83
authored
Dec 07, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache feature check for 5 minutes for MethodCall instrumentation toggle
parent
ad1c186e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+3
-1
spec/lib/gitlab/metrics/method_call_spec.rb
spec/lib/gitlab/metrics/method_call_spec.rb
+11
-0
No files found.
lib/gitlab/metrics/method_call.rb
View file @
53dc9e83
...
...
@@ -72,7 +72,9 @@ module Gitlab
end
def
call_measurement_enabled?
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enabled?
Rails
.
cache
.
fetch
(
:prometheus_metrics_method_instrumentation_enabled
,
expires_in:
5
.
minutes
)
do
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enabled?
end
end
end
end
...
...
spec/lib/gitlab/metrics/method_call_spec.rb
View file @
53dc9e83
...
...
@@ -23,6 +23,17 @@ describe Gitlab::Metrics::MethodCall do
Feature
.
get
(
:prometheus_metrics_method_instrumentation
).
enable
end
it
'feature check is cached for 5 minutes'
do
allow
(
Feature
.
get
(
:prometheus_metrics_method_instrumentation
)).
to
receive
(
:enabled?
).
and_call_original
allow
(
Rails
.
cache
).
to
receive
(
:fetch
).
and_call_original
method_call
.
measure
{
'foo'
}
method_call
.
measure
{
'foo'
}
expect
(
Feature
.
get
(
:prometheus_metrics_method_instrumentation
)).
to
have_received
(
:enabled?
).
twice
expect
(
Rails
.
cache
).
to
have_received
(
:fetch
).
with
(
:prometheus_metrics_method_instrumentation_enabled
,
expires_in:
5
.
minutes
).
twice
end
it
'observes the performance of the supplied block'
do
expect
(
described_class
.
call_duration_histogram
)
.
to
receive
(
:observe
)
...
...
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