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
f5383578
Commit
f5383578
authored
Jan 19, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NullMetric as a singleton
parent
3e898be8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
3 deletions
+7
-3
concern.rb
lib/gitlab/metrics/concern.rb
+1
-1
null_metric.rb
lib/gitlab/metrics/null_metric.rb
+2
-0
prometheus.rb
lib/gitlab/metrics/prometheus.rb
+1
-1
concern_spec.rb
spec/lib/gitlab/metrics/concern_spec.rb
+3
-1
No files found.
lib/gitlab/metrics/concern.rb
View file @
f5383578
...
...
@@ -34,7 +34,7 @@ module Gitlab
options
.
evaluate
(
&
block
)
if
disabled_by_feature
(
options
)
synchronized_cache_fill
(
name
)
{
NullMetric
.
new
}
synchronized_cache_fill
(
name
)
{
NullMetric
.
instance
}
else
synchronized_cache_fill
(
name
)
{
build_metric!
(
type
,
name
,
options
)
}
end
...
...
lib/gitlab/metrics/null_metric.rb
View file @
f5383578
...
...
@@ -2,6 +2,8 @@ module Gitlab
module
Metrics
# Mocks ::Prometheus::Client::Metric and all derived metrics
class
NullMetric
include
Singleton
def
method_missing
(
name
,
*
args
,
&
block
)
nil
end
...
...
lib/gitlab/metrics/prometheus.rb
View file @
f5383578
...
...
@@ -64,7 +64,7 @@ module Gitlab
if
prometheus_metrics_enabled?
registry
.
get
(
name
)
else
NullMetric
.
new
NullMetric
.
instance
end
end
...
...
spec/lib/gitlab/metrics/concern_spec.rb
View file @
f5383578
...
...
@@ -53,7 +53,9 @@ describe Gitlab::Metrics::Concern do
describe
"#fetch_
#{
metric_type
}
"
do
let
(
:fetch_method
)
{
"fetch_
#{
metric_type
}
"
.
to_sym
}
let
(
:null_metric
)
{
Gitlab
::
Metrics
::
NullMetric
.
new
}
let
(
:_metric_type
)
{
metric_type
}
let
(
:null_metric
)
{
Gitlab
::
Metrics
::
NullMetric
.
instance
}
context
"when
#{
metric_type
}
is not cached"
do
it
'initializes counter metric'
do
...
...
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