Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
352bc7d2
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
352bc7d2
编写于
4月 05, 2016
作者:
Y
Yorick Peterse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added dev guide for measuring Ruby blocks
上级
1af6cf28
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
0 deletion
+38
-0
doc/development/README.md
doc/development/README.md
+1
-0
doc/development/instrumentation.md
doc/development/instrumentation.md
+37
-0
未找到文件。
doc/development/README.md
浏览文件 @
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
浏览文件 @
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
```
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录