Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Newdigate <andrew@gitlab.com>2019-01-16 16:29:05 +0300
committerAndrew Newdigate <andrew@gitlab.com>2019-01-16 16:29:05 +0300
commit2c0d69d310489af72f8689a07f3a28efd8065d8c (patch)
treeaaa365e76da2c258a7fa4431b1ccce2efa4124e0
parenteec16ee28c7b377101ab3d5f81835cd8c2020981 (diff)
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.
-rw-r--r--changelogs/unreleased/an-gilab-process-name.yml5
-rw-r--r--config/initializers/sentry.rb2
-rw-r--r--lib/gitlab.rb8
-rw-r--r--lib/gitlab/sentry.rb8
4 files changed, 14 insertions, 9 deletions
diff --git a/changelogs/unreleased/an-gilab-process-name.yml b/changelogs/unreleased/an-gilab-process-name.yml
new file mode 100644
index 00000000000..72d811ee21f
--- /dev/null
+++ b/changelogs/unreleased/an-gilab-process-name.yml
@@ -0,0 +1,5 @@
+---
+title: Extract process_name from GitLab::Sentry
+merge_request: 24422
+author:
+type: other
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb
index 2a6c5148f71..abc91c3ae51 100644
--- a/config/initializers/sentry.rb
+++ b/config/initializers/sentry.rb
@@ -19,7 +19,7 @@ def configure_sentry
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
# Sanitize authentication headers
config.sanitize_http_headers = %w[Authorization Private-Token]
- config.tags = { program: Gitlab::Sentry.program_context }
+ config.tags = { program: Gitlab.process_name }
end
end
end
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
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb
index 46d01964eac..956c16117f5 100644
--- a/lib/gitlab/sentry.rb
+++ b/lib/gitlab/sentry.rb
@@ -52,14 +52,6 @@ module Gitlab
end
end
- def self.program_context
- if Sidekiq.server?
- 'sidekiq'
- else
- 'rails'
- end
- end
-
def self.should_raise_for_dev?
Rails.env.development? || Rails.env.test?
end