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
e5d61415
Commit
e5d61415
authored
Jan 13, 2018
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Actually make the new methods work
parent
ef44fef1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
23 deletions
+27
-23
lib/gitlab/metrics/concern.rb
lib/gitlab/metrics/concern.rb
+25
-22
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+2
-1
No files found.
lib/gitlab/metrics/concern.rb
View file @
e5d61415
...
...
@@ -9,7 +9,7 @@ module Gitlab
@@_metrics_provider_mutex
||=
Mutex
.
new
if
instance_methods
(
false
).
include?
(
name
)
raise
ArgumentError
,
"metrics
class
method
#{
name
}
already exists"
raise
ArgumentError
,
"metrics method
#{
name
}
already exists"
end
options
[
:base_labels
]
||=
{}
...
...
@@ -24,55 +24,58 @@ module Gitlab
args
<<
options
[
:buckets
].
inspect
end
metric_fetching_code
=
%{Gitlab::Metrics
::Prometheus
.#{type}(#{args.join(', ')})}
metric_fetching_code
=
%{Gitlab::Metrics.#{type}(#{args.join(', ')})}
# optionally wrap in feature
metric_fetching_code
=
if
options
[
:with_feature
].
is_a?
(
Symbol
)
<<-
FETCH
.
strip_heredoc
if Feature.get(
#{
options
[
:with_feature
].
inspect
}
).enabled?
#{
metric_fetching_code
}
else
Gitlab::Metrics::NullMetric.new
end
FETCH
end
if
options
[
:with_feature
].
is_a?
(
Symbol
)
metric_fetching_code
=
<<-
FETCH
.
strip_heredoc
if Feature.get(
#{
options
[
:with_feature
].
inspect
}
).enabled?
#{
metric_fetching_code
}
else
Gitlab::Metrics::NullMetric.new
end
FETCH
end
method_code
,
line
=
<<-
METRIC
,
__LINE__
+
1
@@_metric_provider_cached_
#{
name
}
= nil
def
#{
name
}
@@_metric_provider_cached_
#{
name
}
if @@_metric_provider_cached_
#{
name
}
return
@@_metric_provider_cached_
#{
name
}
if @@_metric_provider_cached_
#{
name
}
@@_metrics_provider_mutex.synchronize do
@_metric_provider_cached_
#{
name
}
||=
#{
metric_fetching_code
}
puts "Initiaalized"
@@_metric_provider_cached_
#{
name
}
||=
#{
metric_fetching_code
}
end
end
METRIC
puts
method_code
class
_eval
(
method_code
,
__FILE__
,
line
)
instance
_eval
(
method_code
,
__FILE__
,
line
)
module_eval
(
method_code
,
__FILE__
,
line
)
end
# Declare a Counter
# @param [Symbol] name
# @param [String] docstring
# @param [Hash] opts
def
counter
(
name
,
docstring
,
opts
=
{})
# @param [Hash] opt
ion
s
def
counter
(
name
,
docstring
,
opt
ion
s
=
{})
metrics_provider
(
:counter
,
name
,
docstring
,
options
)
end
# Declare a Gauge
# @param [Symbol] name
# @param [String] docstring
# @param [Hash] opts
def
gauge
(
name
,
docstring
,
opts
=
{})
metrics_provider
(
:counter
,
name
,
docstring
,
opts
)
# @param [Hash] opt
ion
s
def
gauge
(
name
,
docstring
,
opt
ion
s
=
{})
metrics_provider
(
:counter
,
name
,
docstring
,
opt
ion
s
)
end
# Declare a Histograam
# @param [Symbol] name
# @param [String] docstring
# @param [Hash] opts
def
histogram
(
name
,
docstring
,
opts
=
{})
metrics_provider
(
:histogram
,
name
,
docstring
,
opts
)
# @param [Hash] opt
ion
s
def
histogram
(
name
,
docstring
,
opt
ion
s
=
{})
metrics_provider
(
:histogram
,
name
,
docstring
,
opt
ion
s
)
end
def
summary
(
*
args
)
...
...
lib/gitlab/metrics/method_call.rb
View file @
e5d61415
...
...
@@ -10,7 +10,8 @@ module Gitlab
histogram
:gitlab_method_call_duration_seconds
,
'Method calls real duration'
,
base_labels:
Transaction
::
BASE_LABELS
.
merge
(
BASE_LABELS
),
buckets:
[
0.01
,
0.05
,
0.1
,
0.5
,
1
]
buckets:
[
0.01
,
0.05
,
0.1
,
0.5
,
1
],
with_feature: :prometheus_metrics_method_instrumentation
# name - The full name of the method (including namespace) such as
# `User#sign_in`.
...
...
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