From 25ceb77cd0fa9d1683e45eae85e33e82cc9e1823 Mon Sep 17 00:00:00 2001 From: Evgeny Seregin Date: Tue, 28 Feb 2023 17:36:23 +0300 Subject: [PATCH] Docs for new ARQ integration (#6363) --- src/platforms/python/guides/arq/index.mdx | 73 +++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/platforms/python/guides/arq/index.mdx diff --git a/src/platforms/python/guides/arq/index.mdx b/src/platforms/python/guides/arq/index.mdx new file mode 100644 index 0000000000000..286f3902e030c --- /dev/null +++ b/src/platforms/python/guides/arq/index.mdx @@ -0,0 +1,73 @@ +--- +title: ARQ +description: "Learn about using Sentry with ARQ." +--- + +The ARQ integration adds support for the [ARQ Job Queue System](https://arq-docs.helpmanual.io/). + +## Install + +Install `sentry-sdk` from PyPI with the `arq` extra. + +```bash +pip install --upgrade "sentry-sdk[arq]" +``` + +## Configure + +Job definition in `demo.py`: + +```python +import sentry_sdk +from sentry_sdk.integrations.arq import ArqIntegration + + +sentry_sdk.init( + dsn="...", + integrations=[ + ArqIntegration(), + ], + traces_sample_rate=1.0, +) + + +async def add_numbers(ctx, a, b): + return a + b + + +class WorkerSettings: + functions = [add_numbers] +``` + +Running the jobs in `run.py`: + +```python +import asyncio +import sentry_sdk +from sentry_sdk.integrations.arq import ArqIntegration +from sentry_sdk.tracing import TRANSACTION_SOURCE_COMPONENT + + +async def main(): + sentry_sdk.init( + dsn="...", + integrations=[ + ArqIntegration(), + ], + traces_sample_rate=1.0, + ) + + redis = await create_pool(RedisSettings()) + + with sentry_sdk.start_transaction(name="testing_arq_jobs", source=TRANSACTION_SOURCE_COMPONENT): + r = await redis.enqueue_job("download_content", 1, 2) + + +if __name__ == "__main__": + asyncio.run(main()) +``` + +## Supported Versions + +- ARQ: 0.23+ +- Python: 3.7+