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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
f5caa876
Commit
f5caa876
authored
Jul 04, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ac8ed881
ec0796b5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
34 deletions
+21
-34
changelogs/unreleased/63873-process-start-time.yml
changelogs/unreleased/63873-process-start-time.yml
+6
-0
doc/administration/monitoring/prometheus/gitlab_metrics.md
doc/administration/monitoring/prometheus/gitlab_metrics.md
+1
-1
lib/gitlab/metrics/samplers/ruby_sampler.rb
lib/gitlab/metrics/samplers/ruby_sampler.rb
+6
-1
lib/gitlab/metrics/system.rb
lib/gitlab/metrics/system.rb
+0
-12
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
+8
-8
spec/lib/gitlab/metrics/system_spec.rb
spec/lib/gitlab/metrics/system_spec.rb
+0
-12
No files found.
changelogs/unreleased/63873-process-start-time.yml
0 → 100644
View file @
f5caa876
---
title
:
Change ruby_process_start_time_seconds metric to unix timestamp instead of
seconds from boot.
merge_request
:
30195
author
:
type
:
fixed
doc/administration/monitoring/prometheus/gitlab_metrics.md
View file @
f5caa876
...
...
@@ -104,7 +104,7 @@ Some basic Ruby runtime metrics are available:
| ruby_process_cpu_seconds_total | Gauge | 12.0 | Total amount of CPU time per process |
| ruby_process_max_fds | Gauge | 12.0 | Maximum number of open file descriptors per process |
| ruby_process_resident_memory_bytes | Gauge | 12.0 | Memory usage by process, measured in bytes |
| ruby_process_start_time_seconds | Gauge | 12.0 |
The elapsed time between system boot and the process started, measured in seconds
|
| ruby_process_start_time_seconds | Gauge | 12.0 |
UNIX timestamp of process start time
|
[
GC.stat
]:
https://ruby-doc.org/core-2.3.0/GC.html#method-c-stat
...
...
lib/gitlab/metrics/samplers/ruby_sampler.rb
View file @
f5caa876
...
...
@@ -6,6 +6,12 @@ module Gitlab
module
Metrics
module
Samplers
class
RubySampler
<
BaseSampler
def
initialize
(
interval
)
metrics
[
:process_start_time_seconds
].
set
(
labels
.
merge
(
worker_label
),
Time
.
now
.
to_i
)
super
end
def
metrics
@metrics
||=
init_metrics
end
...
...
@@ -47,7 +53,6 @@ module Gitlab
metrics
[
:file_descriptors
].
set
(
labels
.
merge
(
worker_label
),
System
.
file_descriptor_count
)
metrics
[
:process_cpu_seconds_total
].
set
(
labels
.
merge
(
worker_label
),
::
Gitlab
::
Metrics
::
System
.
cpu_time
)
metrics
[
:process_max_fds
].
set
(
labels
.
merge
(
worker_label
),
::
Gitlab
::
Metrics
::
System
.
max_open_file_descriptors
)
metrics
[
:process_start_time_seconds
].
set
(
labels
.
merge
(
worker_label
),
::
Gitlab
::
Metrics
::
System
.
process_start_time
)
set_memory_usage_metrics
sample_gc
...
...
lib/gitlab/metrics/system.rb
View file @
f5caa876
...
...
@@ -31,14 +31,6 @@ module Gitlab
match
[
1
].
to_i
end
def
self
.
process_start_time
fields
=
File
.
read
(
'/proc/self/stat'
).
split
# fields[21] is linux proc stat field "(22) starttime".
# The value is expressed in clock ticks, divide by clock ticks for seconds.
(
fields
[
21
].
to_i
||
0
)
/
clk_tck
end
else
def
self
.
memory_usage
0.0
...
...
@@ -51,10 +43,6 @@ module Gitlab
def
self
.
max_open_file_descriptors
0
end
def
self
.
process_start_time
0
end
end
def
self
.
cpu_time
...
...
spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
View file @
f5caa876
...
...
@@ -8,12 +8,19 @@ describe Gitlab::Metrics::Samplers::RubySampler do
allow
(
Gitlab
::
Metrics
::
NullMetric
).
to
receive
(
:instance
).
and_return
(
null_metric
)
end
describe
'#initialize'
do
it
'sets process_start_time_seconds'
do
Timecop
.
freeze
do
expect
(
sampler
.
metrics
[
:process_start_time_seconds
].
get
).
to
eq
(
Time
.
now
.
to_i
)
end
end
end
describe
'#sample'
do
it
'samples various statistics'
do
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:cpu_time
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:file_descriptor_count
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:memory_usage
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:process_start_time
)
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:max_open_file_descriptors
)
expect
(
sampler
).
to
receive
(
:sample_gc
)
...
...
@@ -44,13 +51,6 @@ describe Gitlab::Metrics::Samplers::RubySampler do
sampler
.
sample
end
it
'adds a metric containing the process start time'
do
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:process_start_time
).
and_return
(
12345
)
expect
(
sampler
.
metrics
[
:process_start_time_seconds
]).
to
receive
(
:set
).
with
({},
12345
)
sampler
.
sample
end
it
'adds a metric containing the process max file descriptors'
do
expect
(
Gitlab
::
Metrics
::
System
).
to
receive
(
:max_open_file_descriptors
).
and_return
(
1024
)
expect
(
sampler
.
metrics
[
:process_max_fds
]).
to
receive
(
:set
).
with
({},
1024
)
...
...
spec/lib/gitlab/metrics/system_spec.rb
View file @
f5caa876
...
...
@@ -19,12 +19,6 @@ describe Gitlab::Metrics::System do
expect
(
described_class
.
max_open_file_descriptors
).
to
be
>
0
end
end
describe
'.process_start_time'
do
it
'returns the process start time'
do
expect
(
described_class
.
process_start_time
).
to
be
>
0
end
end
else
describe
'.memory_usage'
do
it
'returns 0.0'
do
...
...
@@ -43,12 +37,6 @@ describe Gitlab::Metrics::System do
expect
(
described_class
.
max_open_file_descriptors
).
to
eq
(
0
)
end
end
describe
'process_start_time'
do
it
'returns 0'
do
expect
(
described_class
.
process_start_time
).
to
eq
(
0
)
end
end
end
describe
'.cpu_time'
do
...
...
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