Documentation
¶
Overview ¶
Package bugsnag extends the functionalities of the APIs in the bugsnag-go library.
Package bugsnag provides a simple wrapper over the bugsnag/bugsnag-go lib that maintains the same Notify(err, rawData...) API but with improved setup and error decoration.
Usage ¶
The client should only need to use the static/package level APIs defined in bugsnag.go
func main(){ bugsnag.Setup("apiKey", "SHA", "env", []string{"github.com/Shopify/yourClientRepo"}) defer bugsnag.AutoNotify() go func(){ defer bugsnag.AutoRecover() panic("err") } i, err := somethingThatCanError() bugsnag.Notify(err, rawData...) }
Features ¶
Smart handling of errors passed to notify populating the "Error" tab in bugsnag. If the error is wrapped using pkg/errors then its stacktrace and context messages are extracted correctly.
The bugsnag.ErrorClass is set intelligently dealing with go.mod versions. You can also implement the errorClasser interface to override this using the bugsnag.WithErrorClass(err, class) and bugsnag.Wrapf(err, format, args...) helper methods.
Better support for logrus.Fields, *logrus.Entry, *http.Request, *url.Error and *http2.StreamError objects.
HTTP POST request body is extracted into the the Request tab in bugsnag.
Project packages are handled correctly which helps with proper grouping of bugs in bugsnag.
The default panic handler is fixed so that panics are not dropped in containerized environments.
Create custom bugsnag tabs easily by implementing the TabWriter interface or Tab objects passed in as rawData. e.g.:
type customTab struct { val string } func (ct *customTab) CreateBugsnagTab() Tab { return Tab{ Label: "Custom Tab", Rows: Rows{"Key": ct.val}, } } bugsnag.Notify(err, &customTab{"value"})
Index ¶
- func AutoNotify(rawData ...interface{})
- func AutoRecover(rawData ...interface{})
- func Configured() bool
- func Notify(err error, rawData ...interface{})
- func Setup(apiKey string, commit string, env string, packages []string)
- func WithErrorClass(err error, class string) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Rows
- type Tab
- type TabWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoNotify ¶
func AutoNotify(rawData ...interface{})
func AutoRecover ¶
func AutoRecover(rawData ...interface{})
func Configured ¶
func Configured() bool
func WithErrorClass ¶
WithErrorClass wraps the error with an error class used to control the grouping in Bugsnag
Types ¶
type Rows ¶
type Rows map[string]interface{}
Rows is a helper type to make it easier to build bugsnag tab contents, with simple Go literals as in `Tab{"Stuff",Rows{"a":1,"b":2,...}}`.