raven-python icon indicating copy to clipboard operation
raven-python copied to clipboard

[WIP] update celery context

Open ryan-s opened this issue 8 years ago • 4 comments

The current implementation of the celery client prevents the ability to pass context on a per process basis. We have found that being able to tag and filter based on the arguments or key word arguments is immensely helpful in tracking down where failures are in the system.

ryan-s avatar Jan 19 '18 14:01 ryan-s

@ryan-s Mind adding a small test? :) I forgot starting the comment with a thank you.

ashwoods avatar Jan 19 '18 14:01 ashwoods

@ryan-s It's hard to see from the logs (a problem with xdist maybe), but this is still failing three tests:

_______________________________________________________________________ CeleryTestCase.test_context_args ________________________________________________________________________
Traceback (most recent call last):
  File "/Users/ashwoods/Documents/Code/sentry/raven-python/tests/contrib/test_celery.py", line 53, in test_context_args
    assert self.client.context
AssertionError: assert <Context: {}>
 +  where <Context: {}> = <raven.utils.testutils.InMemoryClient object at 0x10eac3e48>.context
 +    where <raven.utils.testutils.InMemoryClient object at 0x10eac3e48> = <tests.contrib.test_celery.CeleryTestCase testMethod=test_context_args>.client
______________________________________________________________________ CeleryTestCase.test_context_kwargs _______________________________________________________________________
Traceback (most recent call last):
  File "/Users/ashwoods/Documents/Code/sentry/raven-python/tests/contrib/test_celery.py", line 60, in test_context_kwargs
    assert self.client.context
AssertionError: assert <Context: {}>
 +  where <Context: {}> = <raven.utils.testutils.InMemoryClient object at 0x10e68d048>.context
 +    where <raven.utils.testutils.InMemoryClient object at 0x10e68d048> = <tests.contrib.test_celery.CeleryTestCase testMethod=test_context_kwargs>.client
__________________________________________________________________________ CeleryTestCase.test_simple ___________________________________________________________________________
Traceback (most recent call last):
  File "/Users/ashwoods/Documents/Code/sentry/raven-python/tests/contrib/test_celery.py", line 36, in test_simple
    assert event['culprit'] == 'dummy_task'
KeyError: 'culprit'

ashwoods avatar Feb 01 '18 09:02 ashwoods

@ashwoods Ill be circling back to this next week. Getting the client to update the context in the logging with the mocks has been problematic. It's also becoming clear that Im conflating the logger and the celery handlers concepts, so I'm going to look to see if there is a more elegant way to handle this.

ryan-s avatar Feb 02 '18 18:02 ryan-s

@ryan-s thx, let me know if there is anything I can do to help.

ashwoods avatar Feb 04 '18 15:02 ashwoods