| ... | @@ -23,32 +23,25 @@ module Gitlab |
... | @@ -23,32 +23,25 @@ module Gitlab |
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def init_metrics
|
|
def init_metrics
|
|
|
metrics = {
|
|
metrics = {}
|
|
|
file_descriptors: ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), 'File descriptors used', labels, :livesum),
|
|
metrics[:sampler_duration] = ::Gitlab::Metrics.counter(with_prefix(:sampler, :duration_seconds_total), 'Sampler time', labels)
|
|
|
memory_bytes: ::Gitlab::Metrics.gauge(with_prefix(:memory, :bytes), 'Memory used', labels, :livesum),
|
|
metrics[:total_time] = ::Gitlab::Metrics.counter(with_prefix(:gc, :duration_seconds_total), 'Total GC time', labels)
|
|
|
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|
|
|
GC.stat.keys.each do |key|
|
|
|
metrics[key] = ::Gitlab::Metrics.gauge(with_prefix(:gc_stat, key), to_doc_string(key), labels, :livesum)
|
|
metrics[key] = ::Gitlab::Metrics.gauge(with_prefix(:gc_stat, key), to_doc_string(key), labels, :livesum)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
metrics[:memory_usage] = ::Gitlab::Metrics.gauge(with_prefix(:memory, :bytes), 'Memory used', labels, :livesum)
|
|
|
|
metrics[:file_descriptors] = ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), 'File descriptors used', labels, :livesum)
|
|
|
|
|
|
|
metrics
|
|
metrics
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def sample
|
|
def sample
|
|
|
start_time = System.monotonic_time
|
|
start_time = System.monotonic_time
|
|
|
|
|
|
|
|
|
metrics[:memory_usage].set(labels.merge(worker_label), System.memory_usage)
|
|
|
metrics[:file_descriptors].set(labels.merge(worker_label), System.file_descriptor_count)
|
|
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
|
|
sample_gc
|
|
|
|
|
|
|
|
metrics[:sampler_duration].increment(labels, System.monotonic_time - start_time)
|
|
metrics[:sampler_duration].increment(labels, System.monotonic_time - start_time)
|
| ... | @@ -68,14 +61,6 @@ module Gitlab |
... | @@ -68,14 +61,6 @@ module Gitlab |
|
|
metrics[:total_time].increment(labels, GC::Profiler.total_time)
|
|
metrics[:total_time].increment(labels, GC::Profiler.total_time)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def set_memory_usage_metrics
|
|
|
|
|
memory_usage = System.memory_usage
|
|
|
|
|
memory_labels = labels.merge(worker_label)
|
|
|
|
|
|
|
|
|
|
metrics[:memory_bytes].set(memory_labels, memory_usage)
|
|
|
|
|
metrics[:process_resident_memory_bytes].set(memory_labels, memory_usage)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def worker_label
|
|
def worker_label
|
|
|
return {} unless defined?(Unicorn::Worker)
|
|
return {} unless defined?(Unicorn::Worker)
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |