Commit e07bfdcc authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'feat/sentry-environment' into 'master'

feat: add option to set Sentry environment

See merge request gitlab-org/gitlab-workhorse!396
parents c769f123 a341fd2a
...@@ -194,17 +194,24 @@ images. If you installed GitLab: ...@@ -194,17 +194,24 @@ images. If you installed GitLab:
GitLab-Workhorse supports remote error tracking with GitLab-Workhorse supports remote error tracking with
[Sentry](https://sentry.io). To enable this feature set the [Sentry](https://sentry.io). To enable this feature set the
GITLAB_WORKHORSE_SENTRY_DSN environment variable. 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`): 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`): Source installations (`/etc/default/gitlab`):
``` ```
export GITLAB_WORKHORSE_SENTRY_DSN='https://foobar' export GITLAB_WORKHORSE_SENTRY_DSN='https://foobar'
export GITLAB_WORKHORSE_SENTRY_ENVIRONMENT='production'
``` ```
## Tests ## Tests
......
...@@ -13,8 +13,13 @@ func wrapRaven(h http.Handler) http.Handler { ...@@ -13,8 +13,13 @@ func wrapRaven(h http.Handler) http.Handler {
// Use a custom environment variable (not SENTRY_DSN) to prevent // Use a custom environment variable (not SENTRY_DSN) to prevent
// clashes with gitlab-rails. // clashes with gitlab-rails.
sentryDSN := os.Getenv("GITLAB_WORKHORSE_SENTRY_DSN") sentryDSN := os.Getenv("GITLAB_WORKHORSE_SENTRY_DSN")
sentryEnvironment := os.Getenv("GITLAB_WORKHORSE_SENTRY_ENVIRONMENT")
raven.SetDSN(sentryDSN) // sentryDSN may be empty raven.SetDSN(sentryDSN) // sentryDSN may be empty
if sentryEnvironment != "" {
raven.SetEnvironment(sentryEnvironment)
}
if sentryDSN == "" { if sentryDSN == "" {
return h return h
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment