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
d9110a7e
Commit
d9110a7e
authored
Apr 11, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track call counts in Gitlab::Metrics.measure_block
parent
185d78bc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
doc/development/instrumentation.md
doc/development/instrumentation.md
+4
-3
lib/gitlab/metrics.rb
lib/gitlab/metrics.rb
+1
-0
spec/lib/gitlab/metrics_spec.rb
spec/lib/gitlab/metrics_spec.rb
+3
-0
No files found.
doc/development/instrumentation.md
View file @
d9110a7e
...
@@ -14,10 +14,11 @@ Gitlab::Metrics.measure(:foo) do
...
@@ -14,10 +14,11 @@ Gitlab::Metrics.measure(:foo) do
end
end
```
```
Two
values are measured for a block:
3
values are measured for a block:
1.
The real time elapsed, stored in NAME_real_time
1.
The real time elapsed, stored in NAME_real_time.
2.
The CPU time elapsed, stored in NAME_cpu_time
2.
The CPU time elapsed, stored in NAME_cpu_time.
3.
The call count, stored in NAME_call_count.
Both the real and CPU timings are measured in milliseconds.
Both the real and CPU timings are measured in milliseconds.
...
...
lib/gitlab/metrics.rb
View file @
d9110a7e
...
@@ -97,6 +97,7 @@ module Gitlab
...
@@ -97,6 +97,7 @@ module Gitlab
Transaction
.
current
.
increment
(
"
#{
name
}
_real_time"
,
real_time
)
Transaction
.
current
.
increment
(
"
#{
name
}
_real_time"
,
real_time
)
Transaction
.
current
.
increment
(
"
#{
name
}
_cpu_time"
,
cpu_time
)
Transaction
.
current
.
increment
(
"
#{
name
}
_cpu_time"
,
cpu_time
)
Transaction
.
current
.
increment
(
"
#{
name
}
_call_count"
,
1
)
retval
retval
end
end
...
...
spec/lib/gitlab/metrics_spec.rb
View file @
d9110a7e
...
@@ -85,6 +85,9 @@ describe Gitlab::Metrics do
...
@@ -85,6 +85,9 @@ describe Gitlab::Metrics do
expect
(
transaction
).
to
receive
(
:increment
).
expect
(
transaction
).
to
receive
(
:increment
).
with
(
'foo_cpu_time'
,
a_kind_of
(
Numeric
))
with
(
'foo_cpu_time'
,
a_kind_of
(
Numeric
))
expect
(
transaction
).
to
receive
(
:increment
).
with
(
'foo_call_count'
,
1
)
Gitlab
::
Metrics
.
measure
(
:foo
)
{
10
}
Gitlab
::
Metrics
.
measure
(
:foo
)
{
10
}
end
end
...
...
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