Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/config/celery.rst

This file was deleted.

32 changes: 9 additions & 23 deletions raven/contrib/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,25 @@
raven.contrib.celery
~~~~~~~~~~~~~~~~~~~~

>>> class CeleryClient(CeleryMixin, Client):
>>> def send_encoded(self, *args, **kwargs):
>>> "Errors through celery"
>>> self.send_raw.delay(*args, **kwargs)

>>> @task(routing_key='sentry')
>>> def send_raw(*args, **kwargs):
>>> return super(client, self).send_encoded(*args, **kwargs)

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import

import logging
try:
from celery.contrib.methods import task
except ImportError:
# Import the pre Celery 3.1 tasks (At some point we'll drop that)
try:
from celery.task import task
except ImportError:
from celery.decorators import task # NOQA
from celery.signals import after_setup_logger, task_failure
from raven.base import Client
from raven.handlers.logging import SentryHandler


class CeleryMixin(object):
def send_encoded(self, *args, **kwargs):
"Errors through celery"
self.send_raw.delay(*args, **kwargs)

@task(routing_key='sentry')
def send_raw(self, *args, **kwargs):
return super(CeleryMixin, self).send_encoded(*args, **kwargs)


class CeleryClient(CeleryMixin, Client):
pass


class CeleryFilter(logging.Filter):
def filter(self, record):
# Context is fixed in Celery 3.x so use internal flag instead
Expand Down
13 changes: 3 additions & 10 deletions raven/contrib/django/celery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,18 @@
"""
from __future__ import absolute_import

from raven.contrib.celery import CeleryMixin
from raven.contrib.django.client import DjangoClient
try:
from celery.contrib.methods import task
from celery.task import task
except ImportError:
# Import the pre Celery 3.1 tasks (At some point we'll drop that)
try:
from celery.task import task
except ImportError:
from celery.decorators import task # NOQA
from celery.decorators import task # NOQA


class CeleryClient(CeleryMixin, DjangoClient):

class CeleryClient(DjangoClient):
def send_integrated(self, kwargs):
return send_raw_integrated.delay(kwargs)

def send_encoded(self, *args, **kwargs):
"Errors through celery"
return send_raw.delay(*args, **kwargs)


Expand Down
Empty file removed tests/contrib/celery/__init__.py
Empty file.
44 changes: 0 additions & 44 deletions tests/contrib/celery/tests.py

This file was deleted.

29 changes: 0 additions & 29 deletions tests/contrib/django/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import re
import sys # NOQA
from exam import fixture
from celery.app import app_or_default

from django.conf import settings
from django.core.exceptions import SuspiciousOperation
Expand Down Expand Up @@ -594,20 +593,6 @@ def test_without_eager(self, send_raw):

self.assertEquals(send_raw.delay.call_count, 1)

# @with_eager_tasks
@mock.patch('raven.contrib.django.DjangoClient.send_encoded')
def test_with_eager(self, send_encoded):
"""
Integration test to ensure it propagates all the way down
and calls the parent client's send_encoded method.
"""
celery_app = app_or_default()
celery_app.conf.CELERY_ALWAYS_EAGER = True
self.client.captureMessage(message='test')

self.assertEquals(send_encoded.call_count, 1)
celery_app.conf.CELERY_ALWAYS_EAGER = False


class CeleryIntegratedClientTest(TestCase):
def setUp(self):
Expand All @@ -631,20 +616,6 @@ def test_without_eager(self, send_raw):

self.assertEquals(send_raw.delay.call_count, 1)

# @with_eager_tasks
@mock.patch('raven.contrib.django.DjangoClient.send_encoded')
def test_with_eager(self, send_encoded):
"""
Integration test to ensure it propagates all the way down
and calls the parent client's send_encoded method.
"""
celery_app = app_or_default()
celery_app.conf.CELERY_ALWAYS_EAGER = True
self.client.captureMessage(message='test')

self.assertEquals(send_encoded.call_count, 1)
celery_app.conf.CELERY_ALWAYS_EAGER = False


class IsValidOriginTestCase(TestCase):
def test_setting_empty(self):
Expand Down