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
1
Merge Requests
1
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
nexedi
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
Show 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)
...
@@ -77,6 +77,7 @@ v 8.9.0 (unreleased)
- All classes in the Banzai::ReferenceParser namespace are now instrumented
- All classes in the Banzai::ReferenceParser namespace are now instrumented
- Remove deprecated issues_tracker and issues_tracker_id from project model
- Remove deprecated issues_tracker and issues_tracker_id from project model
- Allow users to create confidential issues in private projects
- Allow users to create confidential issues in private projects
- Measure CPU time for instrumented methods
v 8.8.5 (unreleased)
v 8.8.5 (unreleased)
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
- Ensure branch cleanup regardless of whether the GitHub import process succeeds
...
...
doc/development/instrumentation.md
View file @
120fbbd4
...
@@ -98,14 +98,15 @@ def #{name}(#{args_signature})
...
@@ -98,14 +98,15 @@ def #{name}(#{args_signature})
if trans
if trans
start = Time.now
start = Time.now
cpu_start = Gitlab::Metrics::System.cpu_time
retval = super
retval = super
duration = (Time.now - start) * 1000.0
duration = (Time.now - start) * 1000.0
if duration >= Gitlab::Metrics.method_call_threshold
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,
trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
{ duration: duration },
{ duration: duration
, cpu_duration: cpu_duration
},
method: #{label.inspect})
method: #{label.inspect})
end
end
...
...
lib/gitlab/metrics/instrumentation.rb
View file @
120fbbd4
...
@@ -150,12 +150,15 @@ module Gitlab
...
@@ -150,12 +150,15 @@ module Gitlab
if trans
if trans
start = Time.now
start = Time.now
cpu_start = Gitlab::Metrics::System.cpu_time
retval = super
retval = super
duration = (Time.now - start) * 1000.0
duration = (Time.now - start) * 1000.0
if duration >= Gitlab::Metrics.method_call_threshold
if duration >= Gitlab::Metrics.method_call_threshold
cpu_duration = Gitlab::Metrics::System.cpu_time - cpu_start
trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
trans.add_metric(Gitlab::Metrics::Instrumentation::SERIES,
{ duration: duration },
{ duration: duration
, cpu_duration: cpu_duration
},
method:
#{
label
.
inspect
}
)
method:
#{
label
.
inspect
}
)
end
end
...
...
spec/lib/gitlab/metrics/instrumentation_spec.rb
View file @
120fbbd4
...
@@ -57,7 +57,7 @@ describe Gitlab::Metrics::Instrumentation do
...
@@ -57,7 +57,7 @@ describe Gitlab::Metrics::Instrumentation do
and_return
(
transaction
)
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_metric
).
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'
)
method:
'Dummy.foo'
)
@dummy
.
foo
@dummy
.
foo
...
@@ -137,7 +137,7 @@ describe Gitlab::Metrics::Instrumentation do
...
@@ -137,7 +137,7 @@ describe Gitlab::Metrics::Instrumentation do
and_return
(
transaction
)
and_return
(
transaction
)
expect
(
transaction
).
to
receive
(
:add_metric
).
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'
)
method:
'Dummy#bar'
)
@dummy
.
new
.
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