Skip to content

Commit 6dfbac0

Browse files
Python: Getting Started arq (#7822)
* Python: Getting Started arq * style(lint): Auto commit lint changes --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent c7efe06 commit 6dfbac0

File tree

2 files changed

+38
-27
lines changed

2 files changed

+38
-27
lines changed

src/platforms/python/common/configuration/integrations/sqlalchemy.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ sentry_sdk.init(
3434
)
3535
```
3636

37-
The Redis integration is enabled automatically if you have the `sqlalchemy` package installed.
37+
The SQLAlchemy integration is enabled automatically if you have the `sqlalchemy` package installed.
3838

3939
## Verify
4040

src/platforms/python/guides/arq/index.mdx

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,57 +15,68 @@ pip install --upgrade "sentry-sdk[arq]"
1515

1616
## Configure
1717

18-
Job definition in `demo.py`:
18+
<SignInNote />
19+
20+
Add `ArqIntegration()` to your `integrations` list:
1921

2022
```python
2123
import sentry_sdk
2224
from sentry_sdk.integrations.arq import ArqIntegration
2325

24-
2526
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,
2731
integrations=[
2832
ArqIntegration(),
2933
],
30-
traces_sample_rate=1.0,
3134
)
35+
```
3236

37+
## Verify
3338

34-
async def add_numbers(ctx, a, b):
35-
return a + b
39+
### Enqueing the jobs in `run.py`:
3640

41+
```python
42+
import asyncio
3743

38-
class WorkerSettings:
39-
functions = [add_numbers]
44+
from arq import create_pool
45+
from arq.connections import RedisSettings
46+
47+
async def main():
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())
4055
```
4156

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`:
4362

4463
```python
45-
import asyncio
4664
import sentry_sdk
4765
from sentry_sdk.integrations.arq import ArqIntegration
48-
from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT
49-
5066

51-
async def main():
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
5968

60-
redis = await create_pool(RedisSettings())
69+
async def add_numbers(ctx, a, b):
70+
1/0 # raises an error!
71+
return a + b
6172

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+
class WorkerSettings:
74+
functions = [add_numbers]
75+
```
6476

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.
6578

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).
6980

7081
## Supported Versions
7182

0 commit comments

Comments
 (0)