Skip to content

Incorrect `unicorn_workers` metric: pid=worker_0 for master process

You could see it there:
https://prometheus-app.gprd.gitlab.net/graph?g0.range_input=1h&g0.expr=unicorn_workers%7Binstance%3D%22api-01-sv-gprd.c.gitlab-production.internal%3A8080%22%7D&g0.tab=1

It seems like unicorn_0 could be the master which is wrongly labelled.

Ben suggested that it may not be related to the way we discover pid but to the fact the metric is only calculated for only single worker (random one, but usually worker_0).
Ben mentioned that :livesum should help, but it's also imprortant to understand why we have this data only in one worker.

Note: worker pid calculated here: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/prometheus/pid_provider.rb#L28, but it seems not directly related

Decision: We'll not use ::Prometheus::Client::Support::Unicorn.worker_id in PidProvider, instead we'll parse $0 like we do for Puma.

Edited by Aleksei Lipniagov