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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
352bc7d2
Commit
352bc7d2
authored
Apr 05, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dev guide for measuring Ruby blocks
parent
1af6cf28
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
doc/development/README.md
doc/development/README.md
+1
-0
doc/development/instrumentation.md
doc/development/instrumentation.md
+37
-0
No files found.
doc/development/README.md
View file @
352bc7d2
...
...
@@ -4,6 +4,7 @@
-
[
CI setup
](
ci_setup.md
)
for testing GitLab
-
[
Gotchas
](
gotchas.md
)
to avoid
-
[
How to dump production data to staging
](
db_dump.md
)
-
[
Instrumentation
](
instrumentation.md
)
-
[
Migration Style Guide
](
migration_style_guide.md
)
for creating safe migrations
-
[
Rake tasks
](
rake_tasks.md
)
for development
-
[
Shell commands
](
shell_commands.md
)
in the GitLab codebase
...
...
doc/development/instrumentation.md
0 → 100644
View file @
352bc7d2
# Instrumenting Ruby Code
GitLab Performance Monitoring allows instrumenting of custom blocks of Ruby
code. This can be used to measure the time spent in a specific part of a larger
chunk of code. The resulting data is written to a separate series.
To start measuring a block of Ruby code you should use
`Gitlab::Metrics.measure`
and give it a name for the series to store the data
in:
```
ruby
Gitlab
::
Metrics
.
measure
(
:user_logins
)
do
...
end
```
The first argument of this method is the series name and should be plural. This
name will be prefixed with
`rails_`
or
`sidekiq_`
depending on whether the code
was run in the Rails application or one of the Sidekiq workers. In the
above example the final series names would be as follows:
-
rails_user_logins
-
sidekiq_user_logins
Series names should be plural as this keeps the naming style in line with the
other series names.
By default metrics measured using a block contain a single value, "duration",
which contains the number of milliseconds it took to execute the block. Custom
values can be added by passing a Hash as the 2nd argument. Custom tags can be
added by passing a Hash as the 3rd argument. A simple example is as follows:
```
ruby
Gitlab
::
Metrics
.
measure
(
:example_series
,
{
number:
10
},
{
class:
self
.
class
.
to_s
})
do
...
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