Issue working with Sentry celery integration
See original GitHub issueI’m trying to use celery-once
with the Sentry celery integration, but I’m running into an issue with how Sentry patches the task tracer.
The issue I’m seeing is that the key before and after the task is patched are different. I believe this is because of how inspect.getcallargs
is working with Sentry’s wrapped run
method.
Would there be anything wrong with storing the key on the task instance like this:
def get_key(self, args=None, kwargs=None):
"""
Generate the key from the name of the task (e.g. 'tasks.example') and
args/kwargs.
"""
if not hasattr(self, '_key'):
restrict_to = self.once.get('keys', None)
args = args or {}
kwargs = kwargs or {}
call_args = getcallargs(
getattr(self, '_orig_run', self.run), *args, **kwargs)
# Remove the task instance from the kwargs. This only happens when the
# task has the 'bind' attribute set to True. We remove it, as the task
# has a memory pointer in its repr, that will change between the task
# caller and the celery worker
if isinstance(call_args.get('self'), Task):
del call_args['self']
self._key = queue_once_key(self.name, call_args, restrict_to)
return self._key
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Celery - Sentry Documentation
The Celery integration adds support for the Celery Task Queue System . ... Additionally, the Sentry Python SDK will set the transaction on...
Read more >Celery integration not capturing error with ... - GitHub
The celery integration is failing to capture the exception when I use a celery factory pattern which patches the celery task with Flask's ......
Read more >How to integrate Sentry for Django and Celery?
Sentry · Go to Sentry and signup · Create a new project and select Django · pip install sentry-sdk install the sentry SDK...
Read more >Celery tasks uncaught exceptions not being sent to Sentry
I only see in Sentry the log.error(...) but not the IndexError uncaught exception. I've tried using a try-except block around the ...
Read more >Performance Monitoring for Celery | Sentry Documentation
Performance Monitoring is available for the Sentry Python SDK version ≥ 0.11.2. ... (The Flask integration, for example, will send a transaction for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
3.0.1 should resolve this issue. I’ll re-open if anyone else experiences this.
Can you try 3.0.1 and see if that fixes the error? It changes how keys are generated.