Commit 17708336 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '216597-drop-uss-pss-env-var' into 'master'

Default enable_memory_uss_pss check to true + add docs

Closes #216597

See merge request gitlab-org/gitlab!31707
parents 9bc4eb02 65e2d770
---
title: Ruby metrics now include USS and PSS memory readings
merge_request: 31707
author:
type: added
......@@ -178,16 +178,18 @@ The following metrics are available:
Some basic Ruby runtime metrics are available:
| Metric | Type | Since | Description |
|:------------------------------------ |:--------- |:----- |:----------- |
| `ruby_gc_duration_seconds` | Counter | 11.1 | Time spent by Ruby in GC |
| `ruby_gc_stat_...` | Gauge | 11.1 | Various metrics from [GC.stat](https://ruby-doc.org/core-2.6.5/GC.html#method-c-stat) |
| `ruby_file_descriptors` | Gauge | 11.1 | File descriptors per process |
| `ruby_sampler_duration_seconds` | Counter | 11.1 | Time spent collecting stats |
| `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 |
| `ruby_process_start_time_seconds` | Gauge | 12.0 | UNIX timestamp of process start time |
| Metric | Type | Since | Description |
|:---------------------------------------- |:--------- |:----- |:----------- |
| `ruby_gc_duration_seconds` | Counter | 11.1 | Time spent by Ruby in GC |
| `ruby_gc_stat_...` | Gauge | 11.1 | Various metrics from [GC.stat](https://ruby-doc.org/core-2.6.5/GC.html#method-c-stat) |
| `ruby_file_descriptors` | Gauge | 11.1 | File descriptors per process |
| `ruby_sampler_duration_seconds` | Counter | 11.1 | Time spent collecting stats |
| `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 (RSS/Resident Set Size) |
| `ruby_process_unique_memory_bytes` | Gauge | 13.0 | Memory usage by process (USS/Unique Set Size) |
| `ruby_process_proportional_memory_bytes` | Gauge | 13.0 | Memory usage by process (PSS/Proportional Set Size) |
| `ruby_process_start_time_seconds` | Gauge | 12.0 | UNIX timestamp of process start time |
## Unicorn Metrics
......
......@@ -88,7 +88,7 @@ module Gitlab
def set_memory_usage_metrics
metrics[:process_resident_memory_bytes].set(labels, System.memory_usage_rss)
if Gitlab::Utils.to_boolean(ENV['enable_memory_uss_pss'])
if Gitlab::Utils.to_boolean(ENV['enable_memory_uss_pss'] || '1')
memory_uss_pss = System.memory_usage_uss_pss
metrics[:process_unique_memory_bytes].set(labels, memory_uss_pss[:uss])
metrics[:process_proportional_memory_bytes].set(labels, memory_uss_pss[:pss])
......
......@@ -8,7 +8,6 @@ describe Gitlab::Metrics::Samplers::RubySampler do
before do
allow(Gitlab::Metrics::NullMetric).to receive(:instance).and_return(null_metric)
stub_env('enable_memory_uss_pss', "1")
end
describe '#initialize' do
......@@ -37,6 +36,21 @@ describe Gitlab::Metrics::Samplers::RubySampler do
sampler.sample
end
context 'when USS+PSS sampling is disabled via environment' do
before do
stub_env('enable_memory_uss_pss', "0")
end
it 'does not sample USS or PSS' do
expect(Gitlab::Metrics::System).not_to receive(:memory_usage_uss_pss)
expect(sampler.metrics[:process_unique_memory_bytes]).not_to receive(:set)
expect(sampler.metrics[:process_proportional_memory_bytes]).not_to receive(:set)
sampler.sample
end
end
it 'adds a metric containing the amount of open file descriptors' do
expect(Gitlab::Metrics::System).to receive(:file_descriptor_count)
.and_return(4)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment