Ignore Puma empty worker stats
In some cases (during worker start) it's possible that Puma.stats returns an empty hash for worker's last status. In that case we just skip sampling of the worker until these stats are available.
This commit is contained in:
parent
5915dec667
commit
d4a83ce5a3
2 changed files with 29 additions and 1 deletions
|
@ -51,10 +51,11 @@ module Gitlab
|
||||||
set_master_metrics(stats)
|
set_master_metrics(stats)
|
||||||
|
|
||||||
stats['worker_status'].each do |worker|
|
stats['worker_status'].each do |worker|
|
||||||
|
last_status = worker['last_status']
|
||||||
labels = { worker: "worker_#{worker['index']}" }
|
labels = { worker: "worker_#{worker['index']}" }
|
||||||
|
|
||||||
metrics[:puma_phase].set(labels, worker['phase'])
|
metrics[:puma_phase].set(labels, worker['phase'])
|
||||||
set_worker_metrics(worker['last_status'], labels)
|
set_worker_metrics(last_status, labels) if last_status.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,33 @@ describe Gitlab::Metrics::Samplers::PumaSampler do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with empty worker stats' do
|
||||||
|
let(:puma_stats) do
|
||||||
|
<<~EOS
|
||||||
|
{
|
||||||
|
"workers": 2,
|
||||||
|
"phase": 2,
|
||||||
|
"booted_workers": 2,
|
||||||
|
"old_workers": 0,
|
||||||
|
"worker_status": [{
|
||||||
|
"pid": 32534,
|
||||||
|
"index": 0,
|
||||||
|
"phase": 1,
|
||||||
|
"booted": true,
|
||||||
|
"last_checkin": "2019-05-15T07:57:55Z",
|
||||||
|
"last_status": {}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not log worker stats' do
|
||||||
|
expect(subject).not_to receive(:set_worker_metrics)
|
||||||
|
|
||||||
|
subject.sample
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'in single mode' do
|
context 'in single mode' do
|
||||||
let(:puma_stats) do
|
let(:puma_stats) do
|
||||||
<<~EOS
|
<<~EOS
|
||||||
|
|
Loading…
Reference in a new issue