Introduce `Gitlab.service_name` provider that would give a stable identifier of the context that you run in

In our codebase, we have multiple places where we use Sidekiq.server?, defined(::Puma) and defined?(::Unicorn) and defined?(::Rails::Console) to identify the context we're running in.

We want to keep this logic in a single testable component instead of spreading the implementation details all over the code.

We have Gitlab.process_name with a very similar idea, but it does not cover all possible sources.
We should either update it or introduce something similar (Gitlab.service_name) and enforce its usage over the whole codebase to have a single way calculating this (to replace described calls ^).

It also makes sense to distinguish between master and worker processes of Puma and Unicorn as it is required for our monitoring: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30474#note_192248187

Edited Jul 18, 2019 by Aleksei Lipniagov
Assignee Loading
Time tracking Loading