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
Léo-Paul Géneau
gitlab-ce
Commits
3e898be8
Commit
3e898be8
authored
Jan 18, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid cascading locking
parent
6ff9f028
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
lib/gitlab/metrics/concern.rb
lib/gitlab/metrics/concern.rb
+12
-6
spec/lib/gitlab/metrics/concern_spec.rb
spec/lib/gitlab/metrics/concern_spec.rb
+1
-1
No files found.
lib/gitlab/metrics/concern.rb
View file @
3e898be8
...
...
@@ -33,19 +33,25 @@ module Gitlab
options
=
MetricOptions
.
new
(
opts
)
options
.
evaluate
(
&
block
)
if
disabled_by_feature
(
options
)
synchronized_cache_fill
(
name
)
{
NullMetric
.
new
}
else
synchronized_cache_fill
(
name
)
{
build_metric!
(
type
,
name
,
options
)
}
end
end
def
synchronized_cache_fill
(
key
)
MUTEX
.
synchronize
do
@_metrics_provider_cache
||=
{}
@_metrics_provider_cache
[
name
]
||=
build_metric!
(
type
,
name
,
options
)
@_metrics_provider_cache
[
key
]
||=
yield
end
end
@_metrics_provider_cache
[
name
]
def
disabled_by_feature
(
options
)
options
.
with_feature
&&
!
Feature
.
get
(
options
.
with_feature
).
enabled?
end
def
build_metric!
(
type
,
name
,
options
)
unless
options
.
with_feature
.
nil?
||
Feature
.
get
(
options
.
with_feature
).
enabled?
return
NullMetric
.
new
end
case
type
when
:gauge
Gitlab
::
Metrics
.
gauge
(
name
,
options
.
docstring
,
options
.
base_labels
,
options
.
multiprocess_mode
)
...
...
spec/lib/gitlab/metrics/concern_spec.rb
View file @
3e898be8
...
...
@@ -128,5 +128,5 @@ describe Gitlab::Metrics::Concern do
include_examples
'metric'
,
:counter
,
{}
include_examples
'metric'
,
:gauge
,
{},
:all
include_examples
'metric'
,
:histogram
,
{},
[
0.005
,
0.01
,
0.
025
,
0.05
,
0.1
,
0.25
,
0.5
,
1
,
2.5
,
5
,
10
]
include_examples
'metric'
,
:histogram
,
{},
[
0.005
,
0.01
,
0.
1
,
1
,
10
]
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