-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Updated celery instrumentation documentation #11600
base: master
Are you sure you want to change the base?
Conversation
Bundle ReportChanges will decrease total bundle size by 15 bytes (-0.0%) ⬇️. This is within the configured threshold ✅ Detailed changes
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is generally an improvement, but I am confused by parts of your proposed changes. Please see comments
|
||
### Standalone Setup | ||
To get the most out of Sentry make sure to initialize the Sentry SDK in your Celery worker processes as well as your application that is sending messages to Celery. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make this clearer and more concise:
To get the most out of Sentry make sure to initialize the Sentry SDK in your Celery worker processes as well as your application that is sending messages to Celery. | |
When using Celery without Django, you need to initialize the Sentry SDK in both your application and the Celery worker process. |
|
||
If you're using Celery standalone, there are two ways to set this up: | ||
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need this paragraph – I think this would belong more on a page with general information about the Sentry SDK.
Unless we want to highlight something specific to Celery, I would delete this.
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/). |
|
||
- Initializing the SDK in the configuration file loaded with Celery's `--config` parameter | ||
- Initializing the SDK by hooking it to either the [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#celeryd-init) or [`worker_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#worker-init) signals | ||
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise, I think this should be obvious.
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below. |
app = Celery("tasks", broker="...") | ||
|
||
# Initialize Sentry SDK on Celery startup | ||
@signals.celeryd_init.connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't both signals needed when starting the Celery working in a separate process?
return x + y | ||
``` | ||
|
||
The [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#celeryd-init) signal is triggered when the Celery deamon is started, before the worker processes are spawned. You can use the [`worker_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#worker-init) signal instead if you want to initialize Sentry on start of each worker process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above. If I remember correctly (it has been a while since I played around with Celery), both signals are needed when using a separate Celery worker process (which is recommended). So, this is not an either/or thing, but rather both are needed when using the separate worker process.
|
||
The [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#celeryd-init) signal is triggered when the Celery deamon is started, before the worker processes are spawned. You can use the [`worker_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#worker-init) signal instead if you want to initialize Sentry on start of each worker process. | ||
|
||
#### Setup in Your Application |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused – why is this section separate from the previous one? Is this why you are suggesting using only one of the signals?
This kinda makes it seem like the application and Celery stuff are completely separate. I find it confusing, but maybe it makes sense to users? Really not sure
|
||
## Verify | ||
|
||
To verify if your SDK is initialized on worker start, you can pass `debug=True` to `sentry_sdk.init()` to see extra output when the SDK is initialized. If the output appears during worker startup and not only after a task has started, then it's working properly. | ||
To verify if your SDK is initialized on worker start, you can pass `debug=True` to `sentry_sdk.init()` to see extra output in your Celery logs when the SDK is initialized. If the output appears during worker startup and not only after a task has started, then it's working properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we perhaps add an example of how to get an error in Sentry to this section, like how we do for many of our other integrations? (potentially out of scope for this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more nit
|
||
<PlatformContent includePath="getting-started-config" /> | ||
### Setup Celery (Without Django) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Setup Celery (Without Django) | |
### Setup Celery Without Django |
Remove parentheses to be consistent with the "Setup Celery With Django" section. Alternatively, we could rename the "Setup Celery With Django" section to "Setup Celery (With Django)."
DESCRIBE YOUR PR
Better description on how and where to setup the Python SDK when you use Celery.
Preview Link:
https://sentry-docs-git-antonpirker-pythoncelery-instrumentation.sentry.dev/platforms/python/integrations/celery/
Fixes #9955
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
LEGAL BOILERPLATE
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
EXTRA RESOURCES