You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `ArqIntegration()` to your `integrations` list:
19
21
20
22
```python
21
23
import sentry_sdk
22
24
from sentry_sdk.integrations.arq import ArqIntegration
23
25
24
-
25
26
sentry_sdk.init(
26
-
dsn="...",
27
+
dsn="___PUBLIC_DSN___",
28
+
# Set traces_sample_rate to 1.0 to capture 100%
29
+
# of transactions for performance monitoring.
30
+
traces_sample_rate=1.0,
27
31
integrations=[
28
32
ArqIntegration(),
29
33
],
30
-
traces_sample_rate=1.0,
31
34
)
35
+
```
32
36
37
+
## Verify
33
38
34
-
asyncdefadd_numbers(ctx, a, b):
35
-
return a + b
39
+
### Enqueing the jobs in `run.py`:
36
40
41
+
```python
42
+
import asyncio
37
43
38
-
classWorkerSettings:
39
-
functions = [add_numbers]
44
+
from arq import create_pool
45
+
from arq.connections import RedisSettings
46
+
47
+
asyncdefmain():
48
+
sentry_sdk.init(...) # same as above
49
+
redis =await create_pool(RedisSettings())
50
+
51
+
with sentry_sdk.start_transaction(name="testing_sentry"):
52
+
r =await redis.enqueue_job("add_numbers", 1, 2)
53
+
54
+
asyncio.run(main())
40
55
```
41
56
42
-
Running the jobs in `run.py`:
57
+
When you run `run.sh` it will create a transaction called `testing_sentry` in the Performance section of [sentry.io](https://sentry.io), and create a span for enqueing the job.
58
+
59
+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
60
+
61
+
### Job definition in `demo.py`:
43
62
44
63
```python
45
-
import asyncio
46
64
import sentry_sdk
47
65
from sentry_sdk.integrations.arq import ArqIntegration
48
-
from sentry_sdk.tracing importTRANSACTION_SOURCE_COMPONENT
49
-
50
66
51
-
asyncdefmain():
52
-
sentry_sdk.init(
53
-
dsn="...",
54
-
integrations=[
55
-
ArqIntegration(),
56
-
],
57
-
traces_sample_rate=1.0,
58
-
)
67
+
sentry_sdk.init(...) # same as above
59
68
60
-
redis =await create_pool(RedisSettings())
69
+
asyncdefadd_numbers(ctx, a, b):
70
+
1/0# raises an error!
71
+
return a + b
61
72
62
-
with sentry_sdk.start_transaction(name="testing_arq_jobs", source=TRANSACTION_SOURCE_COMPONENT):
63
-
r =await redis.enqueue_job("download_content", 1, 2)
73
+
classWorkerSettings:
74
+
functions = [add_numbers]
75
+
```
64
76
77
+
When you run a worker with `arq demo.WorkerSettings` it will create a transaction called `add_numbers` in the Performance section of [sentry.io](https://sentry.io), and will also create and issue in Sentry and connect it to the transaction.
65
78
66
-
if__name__=="__main__":
67
-
asyncio.run(main())
68
-
```
79
+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
0 commit comments