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
Tatuya Kamada
gitlab-ce
Commits
120fbbd4
Commit
120fbbd4
authored
Jun 13, 2016
by
Paco Guzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Measure CPU time for instrumented methods
parent
0c0ef7df
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
11 deletions
+16
-11
CHANGELOG
CHANGELOG
+1
-0
doc/development/instrumentation.md
doc/development/instrumentation.md
+6
-5
lib/gitlab/metrics/instrumentation.rb
lib/gitlab/metrics/instrumentation.rb
+7
-4
spec/lib/gitlab/metrics/instrumentation_spec.rb
spec/lib/gitlab/metrics/instrumentation_spec.rb
+2
-2
No files found.
CHANGELOG
View file @
120fbbd4
...
...
@@ -77,6 +77,7 @@ v 8.9.0 (unreleased)
- All classes in the Banzai::ReferenceParser namespace are now instrumented
- Remove deprecated issues_tracker and issues_tracker_id from project model
- Allow users to create confidential issues in private projects
- Measure CPU time for instrumented methods
v 8.8.5 (unreleased)
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
...
...
doc/development/instrumentation.md
View file @
120fbbd4
...
...
@@ -97,15 +97,16 @@ def #{name}(#{args_signature})
trans = Gitlab::Metrics::Instrumentation.transaction
if trans
start = Time.now
retval = super
duration = (Time.now - start) * 1000.0
start = Time.now
cpu_start = Gitlab::Metrics::System.cpu_time
retval = super
duration = (Time.now - start) * 1000.0
if duration >= Gitlab::Metrics.method_call_threshold
trans.increment(:method_duration, duration)
cpu_duration = Gitlab::Metrics::System.cpu_time - cpu_start
trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
{ duration: duration },
{ duration: duration
, cpu_duration: cpu_duration
},
method: #{label.inspect})
end
...
...
lib/gitlab/metrics/instrumentation.rb
View file @
120fbbd4
...
...
@@ -149,13 +149,16 @@ module Gitlab
trans = Gitlab::Metrics::Instrumentation.transaction
if trans
start = Time.now
retval = super
duration = (Time.now - start) * 1000.0
start = Time.now
cpu_start = Gitlab::Metrics::System.cpu_time
retval = super
duration = (Time.now - start) * 1000.0
if duration >= Gitlab::Metrics.method_call_threshold
cpu_duration = Gitlab::Metrics::System.cpu_time - cpu_start
trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
{ duration: duration },
{ duration: duration
, cpu_duration: cpu_duration
},
method:
#{
label
.
inspect
}
)
end
...
...
spec/lib/gitlab/metrics/instrumentation_spec.rb
View file @
120fbbd4
...
...
@@ -57,7 +57,7 @@ describe Gitlab::Metrics::Instrumentation do
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_metric
).
with
(
described_class
::
SERIES
,
an_instance_of
(
Hash
),
with
(
described_class
::
SERIES
,
hash_including
(
:duration
,
:cpu_duration
),
method:
'Dummy.foo'
)
@dummy
.
foo
...
...
@@ -137,7 +137,7 @@ describe Gitlab::Metrics::Instrumentation do
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_metric
).
with
(
described_class
::
SERIES
,
an_instance_of
(
Hash
),
with
(
described_class
::
SERIES
,
hash_including
(
:duration
,
:cpu_duration
),
method:
'Dummy#bar'
)
@dummy
.
new
.
bar
...
...
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