diff --git a/README.md b/README.md index 31ee06bb19587418267e80fd7b9f88daf19ecd66..a841770f185712f015293035e3ba4233e00b90f6 100644 --- a/README.md +++ b/README.md @@ -194,17 +194,24 @@ images. If you installed GitLab: GitLab-Workhorse supports remote error tracking with [Sentry](https://sentry.io). To enable this feature set the GITLAB_WORKHORSE_SENTRY_DSN environment variable. +You can also set the GITLAB_WORKHORSE_SENTRY_ENVIRONMENT environment variable to +use the Sentry environment functionality to separate staging, production and +development. Omnibus (`/etc/gitlab/gitlab.rb`): ``` -gitlab_workhorse['env'] = {'GITLAB_WORKHORSE_SENTRY_DSN' => 'https://foobar'} +gitlab_workhorse['env'] = { + 'GITLAB_WORKHORSE_SENTRY_DSN' => 'https://foobar' + 'GITLAB_WORKHORSE_SENTRY_ENVIRONMENT' => 'production' +} ``` Source installations (`/etc/default/gitlab`): ``` export GITLAB_WORKHORSE_SENTRY_DSN='https://foobar' +export GITLAB_WORKHORSE_SENTRY_ENVIRONMENT='production' ``` ## Tests diff --git a/raven.go b/raven.go index c92fdb4cfefc2662b215a9bf831b27454afbf133..f641203f142b60dd7fe51e948df1df4d5a3cbcd3 100644 --- a/raven.go +++ b/raven.go @@ -13,8 +13,13 @@ func wrapRaven(h http.Handler) http.Handler { // Use a custom environment variable (not SENTRY_DSN) to prevent // clashes with gitlab-rails. sentryDSN := os.Getenv("GITLAB_WORKHORSE_SENTRY_DSN") + sentryEnvironment := os.Getenv("GITLAB_WORKHORSE_SENTRY_ENVIRONMENT") raven.SetDSN(sentryDSN) // sentryDSN may be empty + if sentryEnvironment != "" { + raven.SetEnvironment(sentryEnvironment) + } + if sentryDSN == "" { return h }