summaryrefslogtreecommitdiff
path: root/docs/patterns/sentry.md
blob: 7dab4dc97f9baa8fcceb7882f02fccca5a1f565e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: "RQ: Sending exceptions to Sentry"
layout: patterns
---

## Sending Exceptions to Sentry

[Sentry](https://www.getsentry.com/) is a popular exception gathering service.
RQ allows you to very easily send job exceptions to Sentry. To do this, you'll
need to have [sentry-sdk](https://pypi.org/project/sentry-sdk/) installed.

There are a few ways to start sending job exceptions to Sentry.


### Configuring Sentry Through CLI

Simply invoke the `rqworker` script using the ``--sentry-dsn`` argument.

```console
rq worker --sentry-dsn https://my-dsn@sentry.io/123
```


### Configuring Sentry Through a Config File

Declare `SENTRY_DSN` in RQ's config file like this:

```python
SENTRY_DSN = 'https://my-dsn@sentry.io/123'
```

And run RQ's worker with your config file:

```console
rq worker -c my_settings
```

Visit [this page](https://python-rq.org/docs/workers/#using-a-config-file)
to read more about running RQ using a config file.


### Configuring Sentry Through Environment Variable

Simple set `RQ_SENTRY_DSN` in your environment variable and RQ will
automatically start Sentry integration for you.

```console
RQ_SENTRY_DSN="https://my-dsn@sentry.io/123" rq worker
```