Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
815b8db1
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,发现更多精彩内容 >>
提交
815b8db1
编写于
9月 06, 2017
作者:
P
Pawel Chojnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split call name to module and method name
上级
cc7997d8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
10 deletion
+27
-10
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+11
-2
lib/gitlab/metrics/instrumentation.rb
lib/gitlab/metrics/instrumentation.rb
+2
-1
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+12
-5
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+2
-2
未找到文件。
lib/gitlab/metrics/influx_db.rb
浏览文件 @
815b8db1
...
...
@@ -102,8 +102,17 @@ module Gitlab
real_time
=
(
real_stop
-
real_start
)
*
1000.0
cpu_time
=
cpu_stop
-
cpu_start
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_real_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
{},
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
]).
observe
({},
real_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_cpu_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
{},
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
]).
observe
({},
cpu_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_real_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
Transaction
::
BASE_LABELS
,
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
])
.
observe
(
trans
.
labels
,
real_time
/
1000.0
)
Gitlab
::
Metrics
.
histogram
(
"gitlab_
#{
name
}
_cpu_duration_seconds"
.
to_sym
,
"Measure
#{
name
}
"
,
Transaction
::
BASE_LABELS
,
[
0.01
,
0.02
,
0.05
,
0.1
,
0.2
,
0.5
,
1
,
2
])
.
observe
(
trans
.
labels
,
cpu_time
/
1000.0
)
trans
.
increment
(
"
#{
name
}
_real_time"
,
real_time
,
false
)
trans
.
increment
(
"
#{
name
}
_cpu_time"
,
cpu_time
,
false
)
...
...
lib/gitlab/metrics/instrumentation.rb
浏览文件 @
815b8db1
...
...
@@ -153,7 +153,8 @@ module Gitlab
proxy_module
.
class_eval
<<-
EOF
,
__FILE__
,
__LINE__
+
1
def
#{
name
}
(
#{
args_signature
}
)
if trans = Gitlab::Metrics::Instrumentation.transaction
trans.method_call_for(
#{
label
.
to_sym
.
inspect
}
).measure { super }
trans.method_call_for(
#{
label
.
to_sym
.
inspect
}
,
#{
mod
.
name
.
to_sym
.
inspect
}
,
#{
name
.
to_sym
.
inspect
}
)
.measure { super }
else
super
end
...
...
lib/gitlab/metrics/method_call.rb
浏览文件 @
815b8db1
...
...
@@ -2,13 +2,14 @@ module Gitlab
module
Metrics
# Class for tracking timing information about method calls
class
MethodCall
BASE_LABELS
=
{
module:
nil
,
method:
nil
}
attr_reader
:real_time
,
:cpu_time
,
:call_count
def
self
.
call_real_duration_histogram
@call_real_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_real_duration_seconds
,
'Method calls real duration'
,
Transaction
::
BASE_LABELS
.
merge
(
{
call_name:
nil
}
),
Transaction
::
BASE_LABELS
.
merge
(
BASE_LABELS
),
[
0.1
,
0.2
,
0.5
,
1
,
2
,
5
,
10
]
)
end
...
...
@@ -17,7 +18,7 @@ module Gitlab
@call_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_cpu_duration_seconds
,
'Method calls cpu duration'
,
Transaction
::
BASE_LABELS
.
merge
(
{
call_name:
nil
}
),
Transaction
::
BASE_LABELS
.
merge
(
BASE_LABELS
),
[
0.1
,
0.2
,
0.5
,
1
,
2
,
5
,
10
]
)
end
...
...
@@ -25,7 +26,9 @@ module Gitlab
# name - The full name of the method (including namespace) such as
# `User#sign_in`.
#
def
initialize
(
name
,
transaction
)
def
initialize
(
name
,
module_name
,
method_name
,
transaction
)
@module_name
=
module_name
@method_name
=
method_name
@transaction
=
transaction
@name
=
name
@real_time
=
0
...
...
@@ -44,13 +47,17 @@ module Gitlab
@call_count
+=
1
if
above_threshold?
self
.
class
.
call_real_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
{
call_name:
@name
}
),
@real_time
/
1000.0
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
{
call_name:
@name
}
),
@cpu_time
/
1000.0
)
self
.
class
.
call_real_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
@real_time
/
1000.0
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
@transaction
.
labels
.
merge
(
labels
),
@cpu_time
/
1000.0
)
end
retval
end
def
labels
@labels
||=
{
module:
@module_name
,
method:
@method_name
}
end
# Returns a Metric instance of the current method call.
def
to_metric
Metric
.
new
(
...
...
lib/gitlab/metrics/transaction.rb
浏览文件 @
815b8db1
...
...
@@ -105,9 +105,9 @@ module Gitlab
end
# Returns a MethodCall object for the given name.
def
method_call_for
(
name
)
def
method_call_for
(
name
,
module_name
,
method_name
)
unless
method
=
@methods
[
name
]
@methods
[
name
]
=
method
=
MethodCall
.
new
(
name
,
transaction
)
@methods
[
name
]
=
method
=
MethodCall
.
new
(
name
,
module_name
,
method_name
,
self
)
end
method
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录