The OnBeforeNotify
configuration option allows for modifying reported information by editing fields on bugsnag.Event
.
Any value on an event can be overridden prior to delivery:
bugsnag.OnBeforeNotify(
func(event *bugsnag.Event, config *bugsnag.Configuration) error {
// Change the endpoint context of an event
event.Context = "GET /api/cart@handler"
return nil
})
Or removed altogether:
bugsnag.OnBeforeNotify(
func(event *bugsnag.Event, config *bugsnag.Configuration) error {
// Remove a potentially sensitive parameter from the raw payload data
delete(event.MetaData["params"], "credit_card_param")
return nil
})
If you have your own logging wrapper all of your errors will appear to originate from inside it. You can avoid this problem by constructing an error with a stacktrace manually, and then passing that to Bugsnag.notify:
import (
"github.com/bugsnag/bugsnag-go"
"github.com/bugsnag/bugsnag-go/errors"
)
func LogError(e error) {
// 1 removes one line of stacktrace, so the caller of LogError
// will be at the top.
e = errors.New(e, 1)
bugsnag.Notify(e)
}
If you need to override Bugsnag’s grouping algorithm, you can set the
GroupingHash
in an OnBeforeNotify
:
bugsnag.OnBeforeNotify(
func (event *bugsnag.Event, config *bugsnag.Configuration) error {
event.GroupingHash = calculateGroupingHash(event)
return nil
})
bugsnag.Event
objectContext
A short description of the error location, such as the URL path or top filename from the stack trace.
Note: This is not a context.Context. See bugsnag-context for more details.
Error
The original error which caused the event.
ErrorClass
The name or title of the report sent to Bugsnag
GroupingHash
A hint for how a report should be grouped with other events in a project. All reports with the same grouping hash will be grouped together.
Message
The description or summary of the report sent to Bugsnag
MetaData
Additional information appended to the report, organized as key/value pairs in named sections.
RawData
The raw information available about the event. This structure is not appended to the report directly but is available to cache request information or additional context.
Stacktrace
An array of stack frames leading to the original error.
User
Information about the user who encountered the event
Request
Information about the HTTP request for which the event occurred