Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3cc28601
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,发现更多精彩内容 >>
提交
3cc28601
编写于
9月 05, 2017
作者:
P
Pawel Chojnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup sampling code and fix bug with samplers running without sleep
上级
b6d75b29
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
29 deletion
+20
-29
lib/gitlab/daemon.rb
lib/gitlab/daemon.rb
+1
-1
lib/gitlab/metrics/method_call.rb
lib/gitlab/metrics/method_call.rb
+5
-18
lib/gitlab/metrics/samplers/base_sampler.rb
lib/gitlab/metrics/samplers/base_sampler.rb
+4
-0
lib/gitlab/metrics/samplers/ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+1
-1
lib/gitlab/metrics/transaction.rb
lib/gitlab/metrics/transaction.rb
+9
-9
未找到文件。
lib/gitlab/daemon.rb
浏览文件 @
3cc28601
...
...
@@ -43,7 +43,7 @@ module Gitlab
if
thread
thread
.
wakeup
if
thread
.
alive?
thread
.
join
thread
.
join
unless
Thread
.
current
==
thread
@thread
=
nil
end
end
...
...
lib/gitlab/metrics/method_call.rb
浏览文件 @
3cc28601
...
...
@@ -10,7 +10,7 @@ module Gitlab
def
self
.
call_real_duration_histogram
@call_real_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_real_duration_milliseconds
,
'Method calls real duration'
,
{},
{
call_name:
nil
},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
end
...
...
@@ -18,17 +18,16 @@ module Gitlab
def
self
.
call_cpu_duration_histogram
@call_duration_histogram
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_method_call_cpu_duration_milliseconds
,
'Method calls cpu duration'
,
{},
{
call_name:
nil
},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
1000
])
end
def
initialize
(
name
,
tags
=
{}
)
def
initialize
(
name
)
@name
=
name
@real_time
=
0
@cpu_time
=
0
@call_count
=
0
@tags
=
tags
end
# Measures the real and CPU execution time of the supplied block.
...
...
@@ -42,25 +41,13 @@ module Gitlab
@call_count
+=
1
if
above_threshold?
self
.
class
.
call_real_duration_histogram
.
observe
(
labels
,
@real_time
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
labels
,
@cpu_time
)
self
.
class
.
call_real_duration_histogram
.
observe
(
{
call_name:
@name
}
,
@real_time
)
self
.
class
.
call_cpu_duration_histogram
.
observe
(
{
call_name:
@name
}
,
@cpu_time
)
end
retval
end
def
labels
@labels
||=
@tags
.
merge
(
source_label
).
merge
({
call_name:
@name
})
end
def
source_label
if
Sidekiq
.
server?
{
source:
'sidekiq'
}
else
{
source:
'rails'
}
end
end
# Returns a Metric instance of the current method call.
def
to_metric
Metric
.
new
(
...
...
lib/gitlab/metrics/samplers/base_sampler.rb
浏览文件 @
3cc28601
require
'logger'
module
Gitlab
module
Metrics
module
Samplers
...
...
@@ -43,11 +44,14 @@ module Gitlab
private
attr_reader
:running
def
start_working
@running
=
true
sleep
(
sleep_interval
)
while
running
safe_sample
sleep
(
sleep_interval
)
end
end
...
...
lib/gitlab/metrics/samplers/ruby_sampler.rb
浏览文件 @
3cc28601
...
...
@@ -32,7 +32,7 @@ module Gitlab
def
init_metrics
metrics
=
{}
metrics
[
:sampler_duration
]
=
Gitlab
::
Metrics
.
histogram
(
with_prefix
(
:sampler_duration
,
:seconds
),
'Sampler time'
,
source_label
)
metrics
[
:sampler_duration
]
=
Gitlab
::
Metrics
.
histogram
(
with_prefix
(
:sampler_duration
,
:seconds
),
'Sampler time'
,
{}
)
metrics
[
:total_time
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
:time_total
),
'Total GC time'
,
labels
,
:livesum
)
GC
.
stat
.
keys
.
each
do
|
key
|
metrics
[
key
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
key
),
to_doc_string
(
key
),
labels
,
:livesum
)
...
...
lib/gitlab/metrics/transaction.rb
浏览文件 @
3cc28601
...
...
@@ -43,18 +43,18 @@ module Gitlab
def
self
.
metric_transaction_duration_milliseconds
@metrics_transaction_duration_milliseconds
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_duration_milliseconds
,
'
Method
duration milliseconds'
,
'
Transaction
duration milliseconds'
,
{},
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
200
,
500
,
1000
,
2000
,
5
000
]
[
1
,
2
,
5
,
10
,
20
,
50
,
100
,
500
,
10
000
]
)
end
def
self
.
metric_transaction_allocated_memory_bytes
@metric_transaction_allocated_memory_bytes
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_allocated_memory_bytes
,
'
Method duration millisecond
s'
,
def
self
.
metric_transaction_allocated_memory_
mega
bytes
@metric_transaction_allocated_memory_
mega
bytes
||=
Gitlab
::
Metrics
.
histogram
(
:gitlab_transaction_allocated_memory_
mega
bytes
,
'
Transaction allocated memory byte
s'
,
{},
[
1
000
,
2000
,
5000
,
10000
,
20000
,
50000
,
100000
,
200000
,
500000
,
50000
00
]
[
1
,
2
,
5
,
10
,
20
,
1
00
]
)
end
...
...
@@ -69,8 +69,8 @@ module Gitlab
@memory_after
=
System
.
memory_usage
@finished_at
=
System
.
monotonic_time
self
.
class
.
metric_transaction_duration_milliseconds
.
observe
({},
duration
)
self
.
class
.
metric_transaction_allocated_memory_
bytes
.
observe
({},
allocated_memory
)
Transaction
.
metric_transaction_duration_milliseconds
.
observe
({},
duration
)
Transaction
.
metric_transaction_allocated_memory_mega
bytes
.
observe
({},
allocated_memory
)
Thread
.
current
[
THREAD_KEY
]
=
nil
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录