Honeybadger for Go (golang) 0.0.2 released

This week we released some improvements to our Go client, which reports panics and errors from Go applications.

This week we released some improvements to our Go client, which reports panics and errors from Go applications. Check out the package on GitHub, and read on to learn about the update!

Before notification callbacks

One of the additions that we're most excited about is the honeybadger.BeforeNotify callback, which allows you to ignore or modify error notifications as they occur. For example, you could ignore all errors of a specific type:

honeybadger.BeforeNotify(
  func(notice *honeybadger.Notice) error {
    if notice.ErrorClass == "SkippedError" {
      return fmt.Errorf("Skipping this notification")
    }
    // Return nil to send notification for all other classes.
    return nil
  }
)

...or you could modify the error class for all errors:

honeybadger.BeforeNotify(
  func(notice *honeybadger.Notice) error {
    // Errors in Honeybadger will always have the class name "GenericError".
    notice.ErrorClass = "GenericError"
    return nil
  }
)

Customizing error grouping

Honeybadger groups by the error type and the first line of the stack by default, but in some cases you may want to provide your own grouping strategy. In 0.0.2 we've made this possible by adding support for custom fingerprints. A fingerprint is simply a unique string; all errors that have the same fingerprint will be grouped together in Honeybadger.

A special case for a custom fingerprint in Go is errors.errorString. Because that type is used for many different types of errors in Go, Honeybadger may appear to group unrelated errors together. To work around that, you could group errors.errorString by message instead of type by customizing the fingerprint in a honeybadger.BeforeNotify callback:

honeybadger.BeforeNotify(
  func(notice *honeybadger.Notice) error {
    if notice.ErrorClass == "errors.errorString" {
      notice.Fingerprint = notice.Message
    }
    return nil
  }
)

Note that in this example, the stack is ignored. If you want to group by message and stack, you could append data from notice.Backtrace to the fingerprint string.

Custom notification improvements

If you've handled a panic in your code, but would still like to report the error to Honeybadger, you can use honeybadger.Notify to report the error:

if err != nil {
  honeybadger.Notify(err)
}

In 0.0.2, we've added some extra types which you can use with this API.

Overriding the error class name

Honeybadger uses the class name (in Go this is the type) of the error object to group similar errors together. If your types are often generic (such as errors.errorString), you can improve grouping by overriding the default with our honeybadger.ErrorClass type:

honeybadger.Notify(err, honeybadger.ErrorClass{"CustomClassName"})

Overriding the fingerprint

We also added a new honeybadger.Fingerprint type which allows you to set the fingerprint locally:

honeybadger.Notify(err, honeybadger.Fingerprint{"A unique string"})

Note that any honeybadger.BeforeNotify callbacks may also modify the fingerprint before the notification is sent.

Minor improvements and bugfixes

We also fixed some bugs and made some other minor feature improvements in 0.0.2. Speaking of which, we also added a CHANGELOG.

I hope that these improvements will help you exterminate errors and panics in your Go applications faster. If you haven't tried Honeybadger for Go yet, sign up for a free trial!

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Joshua Wood

    Josh is Honeybadger's resident bug hunter and technical debt collector. Once enthusiastically referred to as a "human exception tracker", he spends his days crafting the middleware, plugins, and gems which keep the 'badger fat and happy through a steady diet of fresh data.

    More articles by Joshua Wood
    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: