summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyan Cobb <rcobb@gitlab.com>2019-04-24 17:05:09 -0600
committerRyan Cobb <rcobb@gitlab.com>2019-04-24 17:05:09 -0600
commitbb27bf4a1c7153f2f5074eb058d8659dd9f198ad (patch)
treea97200488452580d04f50ad16d5ab0d7a26fb95f /lib
parent174a03dfc284781d811df1874ce3cf11d451a8f5 (diff)
downloadgitlab-ce-bb27bf4a1c7153f2f5074eb058d8659dd9f198ad.tar.gz
Update docs and calculate process start time via proc table
This updates monitor docs to reflect the new ruby and unicorn metrics as well as making it so we fetch process start time via the proc table instead of via CLOCK_BOOTTIME
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/metrics/samplers/ruby_sampler.rb18
-rw-r--r--lib/gitlab/metrics/system.rb22
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/gitlab/metrics/samplers/ruby_sampler.rb b/lib/gitlab/metrics/samplers/ruby_sampler.rb
index c4b2224efdf..5740380e63e 100644
--- a/lib/gitlab/metrics/samplers/ruby_sampler.rb
+++ b/lib/gitlab/metrics/samplers/ruby_sampler.rb
@@ -24,13 +24,13 @@ module Gitlab
def init_metrics
metrics = {
- file_descriptors: ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), 'File descriptors used', labels, :livesum),
- memory_usage: ::Gitlab::Metrics.gauge(with_prefix(:memory, :bytes), 'Memory used', labels, :livesum),
- process_cpu_seconds_total: ::Gitlab::Metrics.gauge(:process_cpu_seconds_total, 'Process CPU seconds total'),
- process_max_fds: ::Gitlab::Metrics.gauge(:process_max_fds, 'Process max fds'),
- process_start_time_seconds: ::Gitlab::Metrics.gauge(:process_start_time_seconds, 'Process start time seconds'),
- sampler_duration: ::Gitlab::Metrics.counter(with_prefix(:sampler, :duration_seconds_total), 'Sampler time', labels),
- total_time: ::Gitlab::Metrics.counter(with_prefix(:gc, :duration_seconds_total), 'Total GC time', labels)
+ file_descriptors: ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), 'File descriptors used', labels, :livesum),
+ process_cpu_seconds_total: ::Gitlab::Metrics.gauge(with_prefix(:process, :cpu_seconds_total), 'Process CPU seconds total'),
+ process_max_fds: ::Gitlab::Metrics.gauge(with_prefix(:process, :max_fds), 'Process max fds'),
+ process_resident_memory_bytes: ::Gitlab::Metrics.gauge(with_prefix(:process, :resident_memory_bytes), 'Memory used', labels, :livesum),
+ process_start_time_seconds: ::Gitlab::Metrics.gauge(with_prefix(:process, :start_time_seconds), 'Process start time seconds'),
+ sampler_duration: ::Gitlab::Metrics.counter(with_prefix(:sampler, :duration_seconds_total), 'Sampler time', labels),
+ total_time: ::Gitlab::Metrics.counter(with_prefix(:gc, :duration_seconds_total), 'Total GC time', labels)
}
GC.stat.keys.each do |key|
@@ -44,10 +44,10 @@ module Gitlab
start_time = System.monotonic_time
metrics[:file_descriptors].set(labels.merge(worker_label), System.file_descriptor_count)
- metrics[:memory_usage].set(labels.merge(worker_label), System.memory_usage)
metrics[:process_cpu_seconds_total].set(labels.merge(worker_label), ::Gitlab::Metrics::System.cpu_time)
- metrics[:process_start_time_seconds].set(labels.merge(worker_label), ::Gitlab::Metrics::System.process_start_time)
metrics[:process_max_fds].set(labels.merge(worker_label), ::Gitlab::Metrics::System.max_open_file_descriptors)
+ metrics[:process_resident_memory_bytes].set(labels.merge(worker_label), System.memory_usage)
+ metrics[:process_start_time_seconds].set(labels.merge(worker_label), ::Gitlab::Metrics::System.process_start_time)
sample_gc
metrics[:sampler_duration].increment(labels, System.monotonic_time - start_time)
diff --git a/lib/gitlab/metrics/system.rb b/lib/gitlab/metrics/system.rb
index a269a8688e9..ecd558d7ec7 100644
--- a/lib/gitlab/metrics/system.rb
+++ b/lib/gitlab/metrics/system.rb
@@ -33,6 +33,13 @@ module Gitlab
max_fds
end
+
+ def self.process_start_time
+ start_time_in_jiffies = Sys::ProcTable.ps(pid: Process.pid).starttime
+ return 0 unless start_time_in_jiffies
+
+ start_time_in_jiffies / 100
+ end
else
def self.memory_usage
0.0
@@ -45,6 +52,10 @@ module Gitlab
def self.max_open_file_descriptors
0
end
+
+ def self.process_start_time
+ 0
+ end
end
# THREAD_CPUTIME is not supported on OS X
@@ -60,17 +71,6 @@ module Gitlab
end
end
- # CLOCK_BOOTTIME is not supported on OS X
- if Process.const_defined?(:CLOCK_BOOTTIME)
- def self.process_start_time
- Process
- .clock_gettime(Process::CLOCK_BOOTTIME, :float_second)
- end
- else
- def self.process_start_time
- 0.0
- end
- end
# Returns the current real time in a given precision.
#
# Returns the time as a Float for precision = :float_second.