Configuration options

To configure Bugsnag for your Revel application, you can either call bugsnag.Configure at the start of your application, or set configuration options in your conf/app.conf file. For bugsnag.Configure you pass it a bugsnag.Configuration object containing any of the following values.

The only required configuration is the Bugsnag API key which can be obtained by clicking “Settings” on the top of of your Bugsnag dashboard after signing up. We also recommend you set the ReleaseStage, AppType, and AppVersion if these make sense for your deployment workflow.

APIKey

The Bugsnag API key can be found on your Bugsnag dashboard under “Settings”.

To configure this property, set bugsnag.apikey in your conf/app.conf:

bugsnag.apikey = YOUR_API_KEY_HERE

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    APIKey: "YOUR_API_KEY_HERE",
})

If you want to have multiple different configurations around in one program, you can use bugsnag.New() to create multiple independent instances of Bugsnag.

notifier := bugsnag.New(bugsnag.Configuration{
    APIKey: "YOUR_OTHER_API_KEY",
})

AppType

If your app has multiple components with different configurations, it can be useful when filtering error reports to separate them by the type of app, like HTTP router, worker queues, and more.

To configure this property, set bugsnag.apptype in your conf/app.conf:

bugsnag.apptype = queue

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    AppType: "queue",
})

The default app type is ‘Revel’.

AppVersion

If you use a versioning scheme for deploys of your app, Bugsnag can use the AppVersion to track your releases and only re-open errors if they occur in later version of the app.

To configure this property, set bugsnag.appversion in your conf/app.conf:

bugsnag.appversion = 1.2.3

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    AppVersion: "1.2.3",
})

AutoCaptureSessions

By default, Bugsnag will automatically capture and report session information from your application.

If the notify endpoint is changed and the sessions endpoint is not, this option will be set to false and session tracking will be disabled.

To disable automatic session capturing:

To configure this property, set bugsnag.autocapturesessions in your conf/app.conf:

bugsnag.autocapturesessions = false

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    AutoCaptureSessions: false,
})

If you want control over what is deemed a session, you can switch off automatic session tracking with the above configuration, and call bugsnag.StartSession() when appropriate for your application.

Endpoint

Deprecated: Use Endpoints instead

The Bugsnag endpoint defaults to https://notify.bugsnag.com/. If you’re using Bugsnag on-premise, you should set this to the endpoint of your local instance.

To configure this property, set bugsnag.endpoint in your conf/app.conf:

bugsnag.endpoint = "http://bugsnag.internal:49000/"

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    Endpoint: "http://bugsnag.internal:49000/",
})

Endpoints

By default we will send error reports to notify.bugsnag.com and sessions to sessions.bugsnag.com.

If you are using Bugsnag On-premise you’ll need to set these to your Event Server and Session Server endpoints. If the notify endpoint is set but the sessions endpoint is not, session tracking will be disabled automatically to avoid leaking session information outside of your server configuration, and a warning will be logged.

To set the endpoints:

To configure these properties, set bugsnag.endpoints in your conf/app.conf:

bugsnag.endpoints.notify = "http://bugsnag.internal:49000/"
bugsnag.endpoints.sessions = "http://bugsnag.internal:49001/"

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    Endpoints: bugsnag.Endpoints{
        Notify:   "http://bugsnag.internal:49000/",
        Sessions: "http://bugsnag.internal:49001/",
    }
})

Hostname

The hostname is used to track where errors are coming from in the Bugsnag dashboard. The default value is obtained from os.Hostname() so you won’t often need to change this.

To configure this property, set bugsnag.hostname in your conf/app.conf:

bugsnag.hostname = go1

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    Hostname: "go1",
})

Logger

The Logger to write to in case of an error inside Bugsnag. This defaults to a wrapper around revel.AppLog.

bugsnag.Configure(bugsnag.Configuration{
    Logger: app.Logger,
}

NotifyReleaseStages

The list of release stages to notify in. By default Bugsnag will notify you in all release stages, but you can use this to silence development errors.

To configure this property, set bugsnag.notifyreleasestages in your conf/app.conf:

bugsnag.notifyreleasestages=production,staging

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    NotifyReleaseStages: []string{"production", "staging"},
})

OnBeforeNotify

While it’s nice that you can pass MetaData directly into bugsnag.Notify, bugsnag.AutoNotify, and bugsnag.Recover, this can be a bit cumbersome and inefficient — you’re constructing the meta-data whether or not it will actually be used. A better idea is to pass raw data in to these functions, and add an OnBeforeNotify filter that converts them into MetaData.

For example, lets say our system processes jobs:

type Job struct{
    Retry     bool
    UserId    string
    UserEmail string
    Name      string
    Params    map[string]string
}

You can pass a job directly into bugsnag.Notify:

bugsnag.Notify(err, c.Args["context"], job)

And then add a filter to extract information from that job and attach it to the Bugsnag event:

bugsnag.OnBeforeNotify(
    func(event *bugsnag.Event, config *bugsnag.Configuration) error {

        // Search all the RawData for any *Job pointers that we're passed in
        // to bugsnag.Notify() and friends.
        for _, datum := range event.RawData {
            if job, ok := datum.(*Job); ok {
                // don't notify bugsnag about errors in retries
                if job.Retry {
                    return fmt.Errorf("not notifying about retried jobs")
                }

                // add the job as a tab on Bugsnag.com
                event.MetaData.AddStruct("Job", job)

                // set the user correctly
                event.User = &User{Id: job.UserId, Email: job.UserEmail}
            }
        }

        // continue notifying as normal
        return nil
    })

PanicHandler

The first time Bugsnag is configured, it wraps the running program in a panic handler using panicwrap. This forks a sub-process which monitors unhandled panics. To prevent this, set PanicHandler to func() {} the in a call to bugsnag.Configure in a revel.OnAppStart(). This will prevent bugsnag from being able to notify you about fatal panics.

revel.OnAppStart(func() {
    bugsnag.Configure(bugsnag.Configuration{
        PanicHandler: func() {},
    })
})

ParamsFilters

Sometimes sensitive data is accidentally included in Bugsnag MetaData. You can remove it by setting ParamsFilters. Any key in the MetaData that includes any string in the filters will be redacted. The default is []string{"password", "secret", "authorization", "cookie"}, which prevents fields like password, password_confirmation and secret_answer from being sent.

ParamsFilters also filters out to request headers.

To configure this property, set bugsnag.paramsfilters in your conf/app.conf:

bugsnag.paramsfilters=password,secret

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    ParamsFilters: []string{"password", "secret"},
}

ProjectPackages

In order to determine where a crash happens Bugsnag needs to know which packages you consider to be part of your app (as opposed to a library). By default this is set to []string{revel.ImportPath + "/app/**"}. Strings are matched to package names using filepath.Match.

For matching subpackages within a package you may use the ** notation. For example, github.com/domain/package/** will match all subpackages under package/.

To configure this property, set bugsnag.projectpackages in your conf/app.conf:

bugsnag.projectpackages=github.com/myorg/myapp/*,github.com/myorg/common/*

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    ProjectPackages: []string{"github.com/myorg/myapp/*", "github.com/myorg/common/*"},
}

ReleaseStage

The release stage tracks where your app is deployed. You should set this to production, staging, development or similar as appropriate.

To configure this property, set bugsnag.releasestage in your conf/app.conf:

bugsnag.releasestage = development

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    ReleaseStage: "development",
})

By default, this value will be revel.RunMode.

SourceRoot

The directory where source packages are built and the assumed prefix of package directories. When set, the prefix is trimmed from callstack frame file names before ProjectPackages are stripped, for better readability and error grouping on the Bugsnag dashboard. The default value is $GOPATH/src or $GOROOT/src if $GOPATH is unset. At runtime, $GOROOT is the root used during the Go build. See the Go runtime package documentation for more information

To configure this property, set bugsnag.sourceroot in your conf/app.conf:

bugsnag.sourceroot = /my/source/root/

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    SourceRoot: "/my/source/root",
})

Synchronous

Bugsnag usually starts a new goroutine before sending notifications. This means that notifications can be lost if you do a bugsnag.Notify and then immediately os.Exit. To avoid this problem, set Bugsnag to Synchronous.

To configure this property, set bugsnag.synchronous in your conf/app.conf:

bugsnag.synchronous = true

Alternatively, you can do this configuration using bugsnag.Configure():

bugsnag.Configure(bugsnag.Configuration{
    Synchronous: true,
})

Or just for one error:

bugsnag.Notify(err, bugsnag.Configuration{Synchronous: true})

Transport

The transport configures how Bugsnag makes HTTP requests. By default we use http.DefaultTransport which handles HTTP proxies automatically using the $HTTP_PROXY environment variable.

bugsnag.Configure(bugsnag.Configuration{
    Transport: http.DefaultTransport,
})