airbrake / gobrake

Airbrake notifier for Golang
https://docs.airbrake.io/docs/platforms/go-lang
MIT License
104 stars 42 forks source link
airbrake error-reporting go golang notifier

Gobrake

.github/workflows/test.yml PkgGoDev

Introduction

Gobrake is the official notifier package for Airbrake for the Go programming language. Gobrake provides a minimalist API that enables the ability to send any Go error or panic to the Airbrake dashboard. The library is extremely lightweight, with minimal overhead.

Key features

Installation

When using Go Modules, you do not need to install anything to start using Airbrake with your Go application. Import the package and the go tool will automatically download the latest version of the package when you next build your program.

import (
    "github.com/airbrake/gobrake/v5"
)

With or without Go Modules, to use the latest version of the package, run:

go get github.com/airbrake/gobrake/v5

Installing in a new project

Create a new directory, initialize a new module and go get the library:

mkdir airbrake_example && cd airbrake_example
go mod init airbrake_example
go get github.com/airbrake/gobrake/v5

Example

This is the minimal example that you can use to test Gobrake with your project.

package main

import (
    "errors"

    "github.com/airbrake/gobrake/v5"
)

var airbrake = gobrake.NewNotifierWithOptions(&gobrake.NotifierOptions{
    ProjectId:   <YOUR PROJECT ID>, // <-- Fill in this value
    ProjectKey:  "<YOUR API KEY>", // <-- Fill in this value
    Environment: "production",
})

func main() {
    defer airbrake.Close()

    airbrake.Notify(errors.New("operation failed"), nil)
}

ProjectId & ProjectKey

You must set both ProjectId & ProjectKey.

To find your ProjectId (int64) and ProjectKey (string) navigate to your project's Settings and copy the values from the right sidebar.

id-key

Getting Started

To check the complete Guide, visit our official docs.

API

For complete API description please follow documentation on pkg.go.dev documentation.

Note: Gobrake provides middleware out of the box and you may find our example apps more helpful:

Additional notes

Exception limit

The maximum size of an exception is 64KB. Exceptions that exceed this limit will be truncated to fit the size.

Logging

We support major logging frameworks:

Supported Go versions

The library supports Go v1.17+. The CI file would be the best source of truth because it contains all Go versions that we test against.

Contact

In case you have a problem, question or a bug report, feel free to:

License

The project uses the MIT License. See LICENSE.md for details.