Back to godoc.org
fknsrs.biz/p/bugsnag

Package bugsnag

v1.0.0
Latest Go to latest

The highest tagged major version is .

Published: Dec 22, 2019 | License: BSD-3-Clause | Module: fknsrs.biz/p/bugsnag

Overview

Package bugsnag provides a library for sending data to the bugsnag error reporting service. It differs from the official library by having special support for github.com/facebookgo/stackerr and a more complete data model.

The main benefit of having special support for stackerr is that we can unwrap its stack traces and send them up as individual exceptions to bugsnag. This shows us every point where `stackerr.Wrap(err)` was called, which can help you trace the path of asynchronous errors through your program.

Index

func RegisterErrorConverter

func RegisterErrorConverter(c ErrorConverter)

type App

type App struct {
	Version      string `json:"version"`
	ReleaseStage string `json:"releaseStage"`
	Commit       string `json:"commit"`
}

App represents some information about the application that crashed or encountered an error.

Note that the `Commit` field is non-standard - bugsnag does _not_ actively support this field, so don't annoy them if it doesn't do what you want.

type Client

type Client struct {
	APIKey          string
	URL             string
	NotifierName    string
	NotifierVersion string
	NotifierURL     string
	ProjectPackages []string
	// contains filtered or unexported fields
}

Client holds information to include in requests to bugsnag.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a new Client with the given API key

func (*Client) Errors

func (c *Client) Errors(errs ...error) error

func (*Client) Notifications

func (c *Client) Notifications() int

func (*Client) Notify

func (c *Client) Notify(events []Event) error

Notify sends a set of (maybe just one) events off to bugsnag

func (*Client) ReportPanic

func (c *Client) ReportPanic()

type Device

type Device struct {
	OSVersion string `json:"osVersion"`
	Hostname  string `json:"hostname"`
}

Device represents the device that was accessing the application at the time it crashed, or an error occurred.

type ErrorConverter

type ErrorConverter interface {
	CanConvertError(err error) bool
	ConvertError(err error) Event
}

type Event

type Event struct {
	PayloadVersion payloadVersion                    `json:"payloadVersion"`
	Exceptions     []Exception                       `json:"exceptions,omitempty"`
	Threads        []Thread                          `json:"threads,omitempty"`
	Context        string                            `json:"context,omitempty"`
	GroupingHash   string                            `json:"groupingHash,omitempty"`
	Severity       string                            `json:"severity,omitempty"`
	User           *User                             `json:"user,omitempty"`
	App            *App                              `json:"app,omitempty"`
	Device         *Device                           `json:"device,omitempty"`
	MetaData       map[string]map[string]interface{} `json:"metaData,omitempty"`
}

Event is an event that goes to bugsnag.

Note: the `PayloadVersion` field is a special type that always encodes to `"2"` in JSON, so it doesn't need to be set for the request to work. In fact, whatever you set it to will be ignored. It just needs to exist for bugsnag.

type Exception

type Exception struct {
	ErrorClass string       `json:"errorClass"`
	Message    string       `json:"message"`
	Stacktrace []StackFrame `json:"stacktrace"`
}

Exception represents a single exception.

type StackFrame

type StackFrame struct {
	File         string            `json:"file"`
	LineNumber   int               `json:"lineNumber"`
	ColumnNumber int               `json:"columnNumber"`
	Method       string            `json:"method"`
	InProject    bool              `json:"inProject"`
	Code         map[string]string `json:"code,omitempty"`
}

StackFrame represents a single stack frame, commonly shown as one line in an exception.

type Thread

type Thread struct {
	ID         string       `json:"id"`
	Name       string       `json:"name"`
	Stacktrace []StackFrame `json:"stacktrace"`
}

Thread represents a (background?) thread. Threads should be in an order that makes sense for your application.

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

User represents information about the user affected by the crash or error.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier