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.

SetHttpContext

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)

SetTagsContext

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

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

SetUserContext

Provides information about a User whos 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)

ClearContext

Sets Http, Tags and User back to Nil value.

Copied
raven.ClearContext()

WrapWithExtra

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)
}