Context

All of the Capture* functions accept an additional argument for passing a map of tags as the second argument and context data as remaining ones. Tags in Sentry help categorize data and give you more information about the errors that happened, where other context data is more "environment" specific. Direct low-level Capture call accepts second argument only --- tags, without additional interfaces.

For example:

Copied
raven.CaptureError(err, map[string]string{"browser": "Firefox"}, &raven.Http{
    Method: "GET",
    URL: "https://example.com/raven-go"
})

This data can be either passed directly to Capture* calls or configured globally using functions listed below, if you decide to apply it to all future events.

Provides information about an HTTP call that the Sentry SDK processes when the error happens.

Copied
h := &raven.Http{
    Method: "GET",
    URL: "https://example.com/raven-go",
}
// or
h = raven.NewHttp(req) // where req is an implementation of `*http.Request` interface
raven.SetHttpContext(h)

Add new tags to the context, merging them with existing ones.

Copied
t := map[string]string{"day": "Friday", "sport": "Weightlifting"}
raven.SetTagsContext(t)

Provides information about a User whose session was active when error happened.

Copied
u := &raven.User{
    ID: "1337",
    Username: "kamilogorek",
    Email: "kamil@sentry.io",
    IP: "127.0.0.1",
}
raven.SetUserContext(u)

Sets Http, Tags and User back to Nil value.

Copied
raven.ClearContext()

Wraps error object with an arbitrary key/value pair that the SDK will send to Sentry alongside the original error.

Copied
path := "filename.ext"
f, err := os.Open(path)
if err != nil {
    err = raven.WrapWithExtra(err, map[string]string{"path": path, "cwd": os.Getwd()}
    raven.CaptureErrorAndWait(err, nil)
    log.Panic(err)
}
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").