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
087c9a5e
Commit
087c9a5e
authored
Jan 17, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop warnings
parent
0325c237
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
lib/gitlab/metrics/concern.rb
lib/gitlab/metrics/concern.rb
+18
-18
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+1
-0
No files found.
lib/gitlab/metrics/concern.rb
View file @
087c9a5e
...
...
@@ -4,13 +4,13 @@ module Gitlab
extend
ActiveSupport
::
Concern
included
do
@
@
_metrics_provider_mutex
||=
Mutex
.
new
@
@
_metrics_provider_cache
||=
{}
@_metrics_provider_mutex
||=
Mutex
.
new
@_metrics_provider_cache
||=
{}
end
class_methods
do
def
reload_metric!
(
name
)
@
@
_metrics_provider_cache
.
delete
(
name
)
@_metrics_provider_cache
.
delete
(
name
)
end
private
...
...
@@ -22,7 +22,7 @@ module Gitlab
define_singleton_method
(
name
)
do
# avoid unnecessary method call to speed up metric access
return
@
@_metrics_provider_cache
[
name
]
if
@
@_metrics_provider_cache
.
has_key?
(
name
)
return
@
_metrics_provider_cache
[
name
]
if
@_metrics_provider_cache
.
has_key?
(
name
)
fetch_metric
(
type
,
name
,
opts
,
&
block
)
end
...
...
@@ -30,16 +30,16 @@ module Gitlab
def
fetch_metric
(
type
,
name
,
opts
=
{},
&
block
)
# avoid synchronization to speed up metrics access
return
@
@_metrics_provider_cache
[
name
]
if
@
@_metrics_provider_cache
.
has_key?
(
name
)
return
@
_metrics_provider_cache
[
name
]
if
@_metrics_provider_cache
.
has_key?
(
name
)
options
=
MetricOptions
.
new
(
opts
)
options
.
evaluate
(
&
block
)
@
@
_metrics_provider_mutex
.
synchronize
do
@
@
_metrics_provider_cache
[
name
]
||=
build_metric!
(
type
,
name
,
options
)
@_metrics_provider_mutex
.
synchronize
do
@_metrics_provider_cache
[
name
]
||=
build_metric!
(
type
,
name
,
options
)
end
@
@
_metrics_provider_cache
[
name
]
@_metrics_provider_cache
[
name
]
end
def
build_metric!
(
type
,
name
,
options
)
...
...
@@ -48,16 +48,16 @@ module Gitlab
end
case
type
when
:gauge
Gitlab
::
Metrics
.
gauge
(
name
,
options
.
docstring
,
options
.
base_labels
,
options
.
multiprocess_mode
)
when
:counter
Gitlab
::
Metrics
.
counter
(
name
,
options
.
docstring
,
options
.
base_labels
)
when
:histogram
Gitlab
::
Metrics
.
histogram
(
name
,
options
.
docstring
,
options
.
base_labels
,
options
.
buckets
)
when
:summary
raise
NotImplementedError
,
"summary metrics are not currently supported"
else
raise
ArgumentError
,
"uknown metric type
#{
type
}
"
when
:gauge
Gitlab
::
Metrics
.
gauge
(
name
,
options
.
docstring
,
options
.
base_labels
,
options
.
multiprocess_mode
)
when
:counter
Gitlab
::
Metrics
.
counter
(
name
,
options
.
docstring
,
options
.
base_labels
)
when
:histogram
Gitlab
::
Metrics
.
histogram
(
name
,
options
.
docstring
,
options
.
base_labels
,
options
.
buckets
)
when
:summary
raise
NotImplementedError
,
"summary metrics are not currently supported"
else
raise
ArgumentError
,
"uknown metric type
#{
type
}
"
end
end
...
...
lib/gitlab/metrics/transaction.rb
View file @
087c9a5e
...
...
@@ -153,6 +153,7 @@ module Gitlab
fetch_metric
(
type
,
metric_name
)
do
docstring
"Transaction
#{
prefix
}#{
name
}
#{
type
}
"
base_labels
tags
.
merge
(
BASE_LABELS
)
if
type
==
:gauge
multiprocess_mode
:livesum
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