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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
4c04444e
Commit
4c04444e
authored
Aug 16, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished Ruby Sampler
+ Cleanup sampler, use latest Prometheus gem
parent
0bfe7901
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
19 deletions
+21
-19
config/initializers/7_prometheus_metrics.rb
config/initializers/7_prometheus_metrics.rb
+1
-1
lib/gitlab/metrics/samplers/ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+20
-18
No files found.
config/initializers/7_prometheus_metrics.rb
View file @
4c04444e
...
...
@@ -21,5 +21,5 @@ Sidekiq.configure_server do |config|
end
# if Gitlab::Metrics.prometheus_metrics_enabled?
Gitlab
::
Metrics
::
Samplers
::
RubySampler
.
initialize_instance
(
1
.
second
).
start
Gitlab
::
Metrics
::
Samplers
::
RubySampler
.
initialize_instance
(
60
.
second
).
start
# end
lib/gitlab/metrics/samplers/ruby_sampler.rb
View file @
4c04444e
require
'prometheus/client/support/unicorn'
module
Gitlab
module
Metrics
module
Samplers
class
RubySampler
<
BaseSampler
COUNTS
=
[
:count
,
:minor_gc_count
,
:major_gc_count
]
def
metrics
@metrics
||=
init_metrics
end
...
...
@@ -32,25 +32,30 @@ module Gitlab
def
init_metrics
metrics
=
{}
metrics
[
:sample
s_total
]
=
Gitlab
::
Metrics
.
counter
(
with_prefix
(
:sampler
,
:total
),
'Total count of samples'
)
metrics
[
:sample
r_duration
]
=
Gitlab
::
Metrics
.
histogram
(
with_prefix
(
:sampler_duration
,
:seconds
),
'Sampler time'
,
source_label
)
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
)
end
metrics
[
:objects_total
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:objects
,
:total
),
'Objects total'
,
labels
.
merge
(
class:
nil
),
:livesum
)
metrics
[
:memory_usage
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:memory
,
:usage_total
),
'Memory used total'
,
labels
,
:livesum
)
metrics
[
:file_descriptors
]
=
Gitlab
::
Metrics
.
gauge
(
with_prefix
(
:file
,
:descriptors_total
),
'File descriptors total'
,
labels
,
:livesum
)
metrics
end
def
sample
metrics
[
:samples_total
].
increment
(
labels
)
start_time
=
System
.
monotonic_time
sample_gc
sample_objects
rescue
=>
ex
puts
ex
metrics
[
:memory_usage
].
set
(
labels
,
System
.
memory_usage
)
metrics
[
:file_descriptors
].
set
(
labels
,
System
.
file_descriptor_count
)
metrics
[
:sampler_duration
].
observe
(
source_label
,
(
System
.
monotonic_time
-
start_time
)
/
1000.0
)
ensure
GC
::
Profiler
.
clear
end
private
...
...
@@ -64,13 +69,13 @@ module Gitlab
end
def
sample_objects
ss
_objects
.
each
do
|
name
,
count
|
list
_objects
.
each
do
|
name
,
count
|
metrics
[
:objects_total
].
set
(
labels
.
merge
(
class:
name
),
count
)
end
end
if
Metrics
.
mri?
def
ss
_objects
def
list
_objects
sample
=
Allocations
.
to_hash
counts
=
sample
.
each_with_object
({})
do
|
(
klass
,
count
),
hash
|
name
=
klass
.
name
...
...
@@ -85,12 +90,10 @@ module Gitlab
counts
end
else
def
ss_objects
def
list_objects
end
end
def
source_label
if
Sidekiq
.
server?
{
source:
'sidekiq'
}
...
...
@@ -101,11 +104,10 @@ module Gitlab
def
worker_label
return
{}
unless
defined?
(
Unicorn
::
Worker
)
worker
=
if
defined?
(
Unicorn
::
Worker
)
ObjectSpace
.
each_object
(
Unicorn
::
Worker
)
&
.
first
end
if
worker
{
unicorn:
worker
.
nr
}
worker_no
=
::
Prometheus
::
Client
::
Support
::
Unicorn
.
worker_id
if
worker_no
{
unicorn:
worker_no
}
else
{
unicorn:
'master'
}
end
...
...
@@ -113,4 +115,4 @@ module Gitlab
end
end
end
end
\ No newline at end of file
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