Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
0bfe7901
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,发现更多精彩内容 >>
提交
0bfe7901
编写于
8月 11, 2017
作者:
P
Pawel Chojnacki
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add samples total and cleanup
上级
03b38a4a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
55 addition
and
26 deletion
+55
-26
doc/user/project/integrations/prometheus.md
doc/user/project/integrations/prometheus.md
+2
-0
lib/gitlab/metrics/samplers/ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+53
-26
未找到文件。
doc/user/project/integrations/prometheus.md
浏览文件 @
0bfe7901
...
@@ -14,6 +14,8 @@ the settings page with a default template. To configure the template, see the
...
@@ -14,6 +14,8 @@ the settings page with a default template. To configure the template, see the
## Requirements
## Requirements
[
supported performance metrics
](
https://docs.gitlab.com/ee/user/project/integrations/prometheus_library/metrics.html
)
Integration with Prometheus requires the following:
Integration with Prometheus requires the following:
1.
GitLab 9.0 or higher
1.
GitLab 9.0 or higher
...
...
lib/gitlab/metrics/samplers/ruby_sampler.rb
浏览文件 @
0bfe7901
...
@@ -2,15 +2,14 @@ module Gitlab
...
@@ -2,15 +2,14 @@ module Gitlab
module
Metrics
module
Metrics
module
Samplers
module
Samplers
class
RubySampler
<
BaseSampler
class
RubySampler
<
BaseSampler
COUNTS
=
[
:count
,
:minor_gc_count
,
:major_gc_count
]
COUNTS
=
[
:count
,
:minor_gc_count
,
:major_gc_count
]
def
metrics
def
metrics
@metrics
||=
init_metrics
@metrics
||=
init_metrics
end
end
def
with_prefix
(
name
)
def
with_prefix
(
prefix
,
name
)
"ruby_
gc
_
#{
name
}
"
.
to_sym
"ruby_
#{
prefix
}
_
#{
name
}
"
.
to_sym
end
end
def
to_doc_string
(
name
)
def
to_doc_string
(
name
)
...
@@ -23,22 +22,40 @@ module Gitlab
...
@@ -23,22 +22,40 @@ module Gitlab
def
initialize
(
interval
)
def
initialize
(
interval
)
super
(
interval
)
super
(
interval
)
GC
::
Profiler
.
enable
Rails
.
logger
.
info
(
"123"
)
init_metrics
if
Gitlab
::
Metrics
.
mri?
require
'allocations'
Allocations
.
start
end
end
end
def
init_metrics
def
init_metrics
metrics
=
{}
metrics
=
{}
metrics
[
:total_time
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:total_time
),
to_doc_string
(
:total_time
),
labels
,
:livesum
)
metrics
[
:samples_total
]
=
Gitlab
::
Metrics
.
counter
(
with_prefix
(
:sampler
,
:total
),
'Total count of samples'
)
metrics
[
:total_time
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
:time_total
),
'Total GC time'
,
labels
,
:livesum
)
GC
.
stat
.
keys
.
each
do
|
key
|
GC
.
stat
.
keys
.
each
do
|
key
|
metrics
[
key
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
key
),
to_doc_string
(
key
),
labels
,
:livesum
)
metrics
[
key
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:gc
,
key
),
to_doc_string
(
key
),
labels
,
:livesum
)
end
end
metrics
[
:objects_total
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:objects
,
:total
),
'Objects total'
,
labels
.
merge
(
class:
nil
),
:livesum
)
metrics
metrics
end
end
def
sample
def
sample
metrics
[
:samples_total
].
increment
(
labels
)
sample_gc
sample_objects
rescue
=>
ex
puts
ex
end
private
def
sample_gc
metrics
[
:total_time
].
set
(
labels
,
GC
::
Profiler
.
total_time
*
1000
)
metrics
[
:total_time
].
set
(
labels
,
GC
::
Profiler
.
total_time
*
1000
)
GC
.
stat
.
each
do
|
key
,
value
|
GC
.
stat
.
each
do
|
key
,
value
|
...
@@ -46,6 +63,34 @@ module Gitlab
...
@@ -46,6 +63,34 @@ module Gitlab
end
end
end
end
def
sample_objects
ss_objects
.
each
do
|
name
,
count
|
metrics
[
:objects_total
].
set
(
labels
.
merge
(
class:
name
),
count
)
end
end
if
Metrics
.
mri?
def
ss_objects
sample
=
Allocations
.
to_hash
counts
=
sample
.
each_with_object
({})
do
|
(
klass
,
count
),
hash
|
name
=
klass
.
name
next
unless
name
hash
[
name
]
=
count
end
# Symbols aren't allocated so we'll need to add those manually.
counts
[
'Symbol'
]
=
Symbol
.
all_symbols
.
length
counts
end
else
def
ss_objects
end
end
def
source_label
def
source_label
if
Sidekiq
.
server?
if
Sidekiq
.
server?
{
source:
'sidekiq'
}
{
source:
'sidekiq'
}
...
@@ -65,24 +110,6 @@ module Gitlab
...
@@ -65,24 +110,6 @@ module Gitlab
{
unicorn:
'master'
}
{
unicorn:
'master'
}
end
end
end
end
def
sample_gc
time
=
GC
::
Profiler
.
total_time
*
1000.0
stats
=
GC
.
stat
.
merge
(
total_time:
time
)
# We want the difference of GC runs compared to the last sample, not the
# total amount since the process started.
stats
[
:minor_gc_count
]
=
@last_minor_gc
.
compared_with
(
stats
[
:minor_gc_count
])
stats
[
:major_gc_count
]
=
@last_major_gc
.
compared_with
(
stats
[
:major_gc_count
])
stats
[
:count
]
=
stats
[
:minor_gc_count
]
+
stats
[
:major_gc_count
]
add_metric
(
'gc_statistics'
,
stats
)
end
end
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录