summaryrefslogtreecommitdiff
path: root/lib/gitlab.rb
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2019-01-16 15:29:05 +0200
committerAndrew Newdigate <andrew@gitlab.com>2019-01-16 15:29:05 +0200
commit2c0d69d310489af72f8689a07f3a28efd8065d8c (patch)
treeaaa365e76da2c258a7fa4431b1ccce2efa4124e0 /lib/gitlab.rb
parenteec16ee28c7b377101ab3d5f81835cd8c2020981 (diff)
downloadgitlab-ce-2c0d69d310489af72f8689a07f3a28efd8065d8c.tar.gz
Extract process_name from GitLab::Sentry
GitLab::Sentry has a program_context method to determine whether a Sentry exception occurred in Sidekiq or rails. Since we will need similar functionality for distributed tracing, this change extracts the program_context method into GitLab.process_name for more general consumption.
Diffstat (limited to 'lib/gitlab.rb')
-rw-r--r--lib/gitlab.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index 074d04fc32a..b91394f7f58 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -89,4 +89,12 @@ module Gitlab
def self.dev_env_or_com?
Rails.env.development? || org? || com?
end
+
+ def self.process_name
+ return 'sidekiq' if Sidekiq.server?
+ return 'console' if defined?(Rails::Console)
+ return 'test' if Rails.env.test?
+
+ 'web'
+ end
end