This is the Go client library for http://yellerapp.com. It lets you automatically detect errors in your application, and reports them via Yeller's API, so you can debug and fix them quickly.
import (
"github.com/yeller/yeller-golang"
)
In your program initialization:
// Start yeller in a specific deployment environment
func main() {
yeller.StartEnv("YOUR_API_KEY", "production")
}
When handling errors that you'd like to log to Yeller:
file, err := os.Open("filename.ext")
if err != nil {
// Notify the error by itself, with additional information
// about what was going on when the error happened.
info := make(map[string]interface{})
info["filename"] = "filename.ext"
yeller.NotifyInfo(err, info)
// Alternatively, notify the error by itself, with no additional information.
// yeller.Notify(err)
}
Generally you should log your errors to Yeller at the highest possible level that still has good context information about what happened.
If you're inside an http handler, Yeller can log request information as well:
http.HandleFunc("/foo", func(w http.ResponseWriter, req *http.Request) {
file, err := os.Open("filename.ext")
if err != nil {
// Log an error to yeller with HTTP request information
// in addition to information pertinent to the error.
info := make(map[string]interface{})
info["filename"] = "filename.ext"
yeller.NotifyHTTPInfo(err, request, info)
// Alternatively, just log information about the HTTP request.
yeller.NotifyHTTP(err, request)
}
})
Most golang programs never use panic
intentionally, but it is essential to know when your program panics. Yeller handles that for you, deduplicating panics so even if you have thousands of crashes, you'll be able to distinguish between causes.
func f() {
myFunctionThatPanics()
defer func() {
if r := recover(); r != nil {
yeller.NotifyPanic(r)
}
}()
}
Yeller can highlight stacktrace lines coming from your application, and hide those that don't. This can make a big difference when reading what can otherwise be very long Go stacktraces:
To activate this feature, Yeller has to know which packages are the root of your application, so you have to set them using one of the client starting functions that accepts a package name:
yeller.StartApplicationRoot("YOUR API TOKEN HERE", "/var/go/my/package")
Note that this path is from the compiled directory of the path, not where your application runs in production.
Without this flag set, Yeller will just display the most recent frames in the stacktrace by default.
Note that this doesn't affect which frames you can see - you can always display all the frames:
If you have any questions, feel free to shoot me an email, .
If you're curious about this library, it's open source, and available on: github