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
815b8db1
Commit
815b8db1
authored
Sep 06, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split call name to module and method name
parent
cc7997d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+11
-2
lib/gitlab/metrics/instrumentation.rb
lib/gitlab/metrics/instrumentation.rb
+2
-1
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+12
-5
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+2
-2
No files found.
lib/gitlab/metrics/influx_db.rb
View file @
815b8db1
...
...
@@ -102,8 +102,17 @@ module Gitlab
real_time
=
(
real_stop
-
real_start
)
*
1000.0
cpu_time
=
cpu_stop
-
cpu_start
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_real_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
{},
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
]).
observe
({},
real_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_cpu_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
{},
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
]).
observe
({},
cpu_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_real_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
Transaction
::
BASE_LABELS
,
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
])
.
observe
(
trans
.
labels
,
real_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_cpu_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
Transaction
::
BASE_LABELS
,
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
])
.
observe
(
trans
.
labels
,
cpu_time
/
1000.0
)
trans
.
increment
(
"
#{
name
}
_real_time"
,
real_time
,
false
)
trans
.
increment
(
"
#{
name
}
_cpu_time"
,
cpu_time
,
false
)
...
...
lib/gitlab/metrics/instrumentation.rb
View file @
815b8db1
...
...
@@ -153,7 +153,8 @@ module Gitlab
proxy_module
.
class_eval
<<-
EOF
,
__FILE__
,
__LINE__
+
1
def
#{
name
}
(
#{
args_signature
}
)
if trans = Gitlab::Metrics::Instrumentation.transaction
trans.method_call_for(
#{
label
.
to_sym
.
inspect
}
).measure { super }
trans.method_call_for(
#{
label
.
to_sym
.
inspect
}
,
#{
mod
.
name
.
to_sym
.
inspect
}
,
#{
name
.
to_sym
.
inspect
}
)
.measure { super }
else
super
end
...
...
lib/gitlab/metrics/method_call.rb
View file @
815b8db1
...
...
@@ -2,13 +2,14 @@ module Gitlab
module
Metrics
# Class for tracking timing information about method calls
class
MethodCall
BASE_LABELS
=
{
module:
nil
,
method:
nil
}
attr_reader
:real_time
,
:cpu_time
,
:call_count
def
self
.
call_real_duration_histogram
@call_real_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_real_duration_seconds
,
'Method calls real duration'
,
Transaction
::
BASE_LABELS
.
merge
(
{
call_name:
nil
}
),
Transaction
::
BASE_LABELS
.
merge
(
BASE_LABELS
),
[
0.1
,
0.2
,
0.5
,
1
,
2
,
5
,
10
]
)
end
...
...
@@ -17,7 +18,7 @@ module Gitlab
@call_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_cpu_duration_seconds
,
'Method calls cpu duration'
,
Transaction
::
BASE_LABELS
.
merge
(
{
call_name:
nil
}
),
Transaction
::
BASE_LABELS
.
merge
(
BASE_LABELS
),
[
0.1
,
0.2
,
0.5
,
1
,
2
,
5
,
10
]
)
end
...
...
@@ -25,7 +26,9 @@ module Gitlab
# name - The full name of the method (including namespace) such as
# `User#sign_in`.
#
def
initialize
(
name
,
transaction
)
def
initialize
(
name
,
module_name
,
method_name
,
transaction
)
@module_name
=
module_name
@method_name
=
method_name
@transaction
=
transaction
@name
=
name
@real_time
=
0
...
...
@@ -44,13 +47,17 @@ module Gitlab
@call_count
+=
1
if
above_threshold?
self
.
class
.
call_real_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
{
call_name:
@name
}
),
@real_time
/
1000.0
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
{
call_name:
@name
}
),
@cpu_time
/
1000.0
)
self
.
class
.
call_real_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
@real_time
/
1000.0
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
@cpu_time
/
1000.0
)
end
retval
end
def
labels
@labels
||=
{
module:
@module_name
,
method:
@method_name
}
end
# Returns a Metric instance of the current method call.
def
to_metric
Metric
.
new
(
...
...
lib/gitlab/metrics/transaction.rb
View file @
815b8db1
...
...
@@ -105,9 +105,9 @@ module Gitlab
end
# Returns a MethodCall object for the given name.
def
method_call_for
(
name
)
def
method_call_for
(
name
,
module_name
,
method_name
)
unless
method
=
@methods
[
name
]
@methods
[
name
]
=
method
=
MethodCall
.
new
(
name
,
transaction
)
@methods
[
name
]
=
method
=
MethodCall
.
new
(
name
,
module_name
,
method_name
,
self
)
end
method
...
...
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