Airbrake notifier for Golang
Clone or download

Airbrake Golang Notifier Build Status


package main

import (


var airbrake = gobrake.NewNotifierWithOptions(&gobrake.NotifierOptions{
    ProjectId: 123456,
    ProjectKey: "FIXME",
    Environment: "production",

func init() {
    airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
        notice.Params["user"] = map[string]string{
            "id": "1",
            "username": "johnsmith",
            "name": "John Smith",
        return notice

func main() {
    defer airbrake.Close()
    defer airbrake.NotifyOnPanic()

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

Ignoring notices

airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
    if notice.Context["environment"] == "development" {
        // Ignore notices in development environment.
        return nil
    return notice

Setting severity

Severity allows categorizing how severe an error is. By default, it's set to error. To redefine severity, simply overwrite context/severity of a notice object. For example:

notice := airbrake.Notice("operation failed", nil, 3)
notice.Context["severity"] = "critical"
airbrake.Notify(notice, nil)


You can use glog fork to send your logs to Airbrake.

Sending requests stats

In order to collect some basic requests stats you can instrument your application using Notifier.NotifyRequest API:

    Method:     "GET",
    Route:      "/hello/:name",
    StatusCode: http.StatusOK,
    Start:      startTime,
    End:        time.Now(),

We also prepared HTTP middlewares for Gin and Beego users.