summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-08-31 17:04:23 +0000
committerRobert Speicher <robert@gitlab.com>2016-08-31 17:04:23 +0000
commit347ba7ea414cbd3ffbd5e304513efe71df6fb3a3 (patch)
treed7ea9f28be8c9bd068cc23b9a89699905e238786 /lib
parent933615e8909bf1492a7aca93ec1de5d512fbd787 (diff)
parent0fe4cf2b0fdbc33572f11bba1a4426ee05ed7599 (diff)
downloadgitlab-ce-347ba7ea414cbd3ffbd5e304513efe71df6fb3a3.tar.gz
Merge branch 'fix-sidekiq-sentry-context' into 'master'
Fix Sentry not reporting right program for Sidekiq workers Moves program tag into the global configuration since this doesn't change and since Sidekiq workers get a unique context for each event. Closes #21410 See merge request !6004
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/sentry.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb
new file mode 100644
index 00000000000..117fc508135
--- /dev/null
+++ b/lib/gitlab/sentry.rb
@@ -0,0 +1,27 @@
+module Gitlab
+ module Sentry
+ def self.enabled?
+ Rails.env.production? && current_application_settings.sentry_enabled?
+ end
+
+ def self.context(current_user = nil)
+ return unless self.enabled?
+
+ if current_user
+ Raven.user_context(
+ id: current_user.id,
+ email: current_user.email,
+ username: current_user.username,
+ )
+ end
+ end
+
+ def self.program_context
+ if Sidekiq.server?
+ 'sidekiq'
+ else
+ 'rails'
+ end
+ end
+ end
+end