bugsnag

package
v0.0.0-...-5720ada Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 14 Imported by: 0

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

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 Notify

func Notify(err error, rawData ...interface{})

func Setup

func Setup(apiKey string, commit string, env string, packages []string)

func WithErrorClass

func WithErrorClass(err error, class string) error

WithErrorClass wraps the error with an error class used to control the grouping in Bugsnag

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf acts like errors.Wrapf except it also sets the error class to be equal to the message

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,...}}`.

type Tab

type Tab struct {
	Label string
	Rows  Rows
}

Tab can be used to attach an additional info tab to bugsnag error reports. Just pass it to the Notify function.

type TabWriter

type TabWriter interface {
	CreateBugsnagTab() Tab
}

TabWriter defines the interface to be implemented by the different client objects that want custom decorated bugsnag tabs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL