---
title: "Context"
url: https://docs.sentry.io/platforms/go/legacy-sdk/context/
---

# Context | Sentry for Go

##### Deprecation Warning

A [new Go SDK](https://docs.sentry.io/platforms/go.md) has superseded this deprecated version. Sentry preserves this documentation for customers using the old `raven-go` client. Learn more about the project on [GitHub](https://github.com/getsentry/sentry-go) and check out our [migration guide](https://docs.sentry.io/platforms/go/migration.md).

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:

```go
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`](https://docs.sentry.io/platforms/go/legacy-sdk/context.md#sethttpcontext)

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

```go
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`](https://docs.sentry.io/platforms/go/legacy-sdk/context.md#settagscontext)

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

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

### [`SetUserContext`](https://docs.sentry.io/platforms/go/legacy-sdk/context.md#setusercontext)

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

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

### [`ClearContext`](https://docs.sentry.io/platforms/go/legacy-sdk/context.md#clearcontext)

Sets `Http`, `Tags` and `User` back to `Nil` value.

```go
raven.ClearContext()
```

### [`WrapWithExtra`](https://docs.sentry.io/platforms/go/legacy-sdk/context.md#wrapwithextra)

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

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