summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cramer <dcramer@gmail.com>2015-09-24 12:22:50 -0700
committerDavid Cramer <dcramer@gmail.com>2015-10-08 11:18:23 -0700
commit7c141be192558a076321c36b7424893f3175ec99 (patch)
treeca7caaa574db74eb6b0f68c142d7dbd39dbb0823
parent531afa59fed952605d7f2ef27121f04d2a021ae2 (diff)
downloadraven-remove-culprit.tar.gz
Leave culprit up to the serverremove-culprit
-rw-r--r--docs/integrations/logging.rst2
-rw-r--r--raven/base.py10
-rw-r--r--raven/handlers/logging.py8
-rw-r--r--raven/utils/stacks.py36
-rw-r--r--tests/contrib/django/tests.py30
-rw-r--r--tests/contrib/flask/tests.py1
-rw-r--r--tests/contrib/webpy/tests.py1
-rw-r--r--tests/handlers/logging/tests.py3
-rw-r--r--tests/utils/stacks/tests.py29
9 files changed, 4 insertions, 116 deletions
diff --git a/docs/integrations/logging.rst b/docs/integrations/logging.rst
index da703aa..c865ef9 100644
--- a/docs/integrations/logging.rst
+++ b/docs/integrations/logging.rst
@@ -109,8 +109,8 @@ will be displayed on the Sentry dashboard. To do this, pass it as ``data``
within your ``extra`` clause::
logger.error('There was some crazy error', exc_info=True, extra={
+
# Optionally you can pass additional arguments to specify request info
- 'culprit': 'my.view.name',
'fingerprint': [...],
'data': {
diff --git a/raven/base.py b/raven/base.py
index b6a0f92..3cfdd81 100644
--- a/raven/base.py
+++ b/raven/base.py
@@ -29,7 +29,7 @@ from raven.exceptions import APIError, RateLimited
from raven.utils import six, json, get_versions, get_auth_header, merge_dicts
from raven.utils.encoding import to_unicode
from raven.utils.serializer import transform
-from raven.utils.stacks import get_stack_info, iter_stack_frames, get_culprit
+from raven.utils.stacks import get_stack_info, iter_stack_frames
from raven.transport.registry import TransportRegistry, default_transports
__all__ = ('Client',)
@@ -344,14 +344,6 @@ class Client(object):
not any(path.startswith(x) for x in self.exclude_paths)
)
- if not culprit:
- if 'stacktrace' in data:
- culprit = get_culprit(data['stacktrace']['frames'])
- elif 'exception' in data:
- stacktrace = data['exception']['values'][0].get('stacktrace')
- if stacktrace:
- culprit = get_culprit(stacktrace['frames'])
-
if not data.get('level'):
data['level'] = kwargs.get('level') or logging.ERROR
diff --git a/raven/handlers/logging.py b/raven/handlers/logging.py
index 4af0fba..5bcef5d 100644
--- a/raven/handlers/logging.py
+++ b/raven/handlers/logging.py
@@ -17,7 +17,7 @@ import traceback
from raven.base import Client
from raven.utils import six
from raven.utils.encoding import to_string
-from raven.utils.stacks import iter_stack_frames, label_from_frame
+from raven.utils.stacks import iter_stack_frames
RESERVED = frozenset((
'stack', 'name', 'module', 'funcName', 'args', 'msg', 'levelno',
@@ -157,12 +157,6 @@ class SentryHandler(logging.Handler, object):
event_type = 'raven.events.Exception'
handler_kwargs = {'exc_info': record.exc_info}
- # HACK: discover a culprit when we normally couldn't
- elif not (data.get('stacktrace') or data.get('culprit')) and (record.name or record.funcName):
- culprit = label_from_frame({'module': record.name, 'function': record.funcName})
- if culprit:
- data['culprit'] = culprit
-
data['level'] = record.levelno
data['logger'] = record.name
diff --git a/raven/utils/stacks.py b/raven/utils/stacks.py
index 8dc24a1..c7ed8ae 100644
--- a/raven/utils/stacks.py
+++ b/raven/utils/stacks.py
@@ -10,7 +10,6 @@ from __future__ import absolute_import
import inspect
import re
import sys
-import warnings
from raven.utils.serializer import transform
from raven.utils import six
@@ -83,41 +82,6 @@ def get_lines_from_file(filename, lineno, context_lines, loader=None, module_nam
return pre_context, context_line, post_context
-def label_from_frame(frame):
- module = frame.get('module') or '?'
- function = frame.get('function') or '?'
- if module == function == '?':
- return ''
- return '%s in %s' % (module, function)
-
-
-def get_culprit(frames, *args, **kwargs):
- # We iterate through each frame looking for a deterministic culprit
- # When one is found, we mark it as last "best guess" (best_guess) and then
- # check it against ``exclude_paths``. If it isn't listed, then we
- # use this option. If nothing is found, we use the "best guess".
- if args or kwargs:
- warnings.warn('get_culprit no longer does application detection')
-
- best_guess = None
- culprit = None
- for frame in reversed(frames):
- culprit = label_from_frame(frame)
- if not culprit:
- culprit = None
- continue
-
- if frame.get('in_app'):
- return culprit
- elif not best_guess:
- best_guess = culprit
- elif best_guess:
- break
-
- # Return either the best guess or the last frames call
- return best_guess or culprit
-
-
def _getitem_from_frame(f_locals, key, default=None):
"""
f_locals is not guaranteed to have .get(), but it will always
diff --git a/tests/contrib/django/tests.py b/tests/contrib/django/tests.py
index de4b866..bb3ace1 100644
--- a/tests/contrib/django/tests.py
+++ b/tests/contrib/django/tests.py
@@ -155,7 +155,6 @@ class DjangoClientTest(TestCase):
assert exc['value'], "int() argument must be a string or a number == not 'NoneType'"
assert event['level'] == logging.ERROR
assert event['message'], "TypeError: int() argument must be a string or a number == not 'NoneType'"
- assert event['culprit'] == 'tests.contrib.django.tests in test_signal_integration'
def test_view_exception(self):
self.assertRaises(Exception, self.client.get, reverse('sentry-raise-exc'))
@@ -168,7 +167,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'view exception'
assert event['level'] == logging.ERROR
assert event['message'] == 'Exception: view exception'
- assert event['culprit'] == 'tests.contrib.django.views in raise_exc'
def test_user_info(self):
with Settings(MIDDLEWARE_CLASSES=[
@@ -234,7 +232,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'request'
assert event['level'] == logging.ERROR
assert event['message'] == 'ImportError: request'
- assert event['culprit'] == 'tests.contrib.django.middleware in process_request'
def test_response_middlware_exception(self):
if django.VERSION[:2] < (1, 3):
@@ -251,7 +248,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'response'
assert event['level'] == logging.ERROR
assert event['message'] == 'ImportError: response'
- assert event['culprit'] == 'tests.contrib.django.middleware in process_response'
def test_broken_500_handler_with_middleware(self):
with Settings(BREAK_THAT_500=True, INSTALLED_APPS=['raven.contrib.django']):
@@ -269,7 +265,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'view exception'
assert event['level'] == logging.ERROR
assert event['message'] == 'Exception: view exception'
- assert event['culprit'] == 'tests.contrib.django.views in raise_exc'
event = self.raven.events.pop(0)
@@ -279,7 +274,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'handler500'
assert event['level'] == logging.ERROR
assert event['message'] == 'ValueError: handler500'
- assert event['culprit'] == 'tests.contrib.django.urls in handler500'
def test_view_middleware_exception(self):
with Settings(MIDDLEWARE_CLASSES=['tests.contrib.django.middleware.BrokenViewMiddleware']):
@@ -294,30 +288,6 @@ class DjangoClientTest(TestCase):
assert exc['value'] == 'view'
assert event['level'] == logging.ERROR
assert event['message'] == 'ImportError: view'
- assert event['culprit'] == 'tests.contrib.django.middleware in process_view'
-
- def test_exclude_modules_view(self):
- exclude_paths = self.raven.exclude_paths
- self.raven.exclude_paths = ['tests.views']
- self.assertRaises(Exception, self.client.get, reverse('sentry-raise-exc-decor'))
-
- assert len(self.raven.events) == 1
- event = self.raven.events.pop(0)
-
- assert event['culprit'] == 'tests.contrib.django.views in raise_exc'
- self.raven.exclude_paths = exclude_paths
-
- def test_include_modules(self):
- include_paths = self.raven.include_paths
- self.raven.include_paths = ['django.shortcuts']
-
- self.assertRaises(Exception, self.client.get, reverse('sentry-django-exc'))
-
- assert len(self.raven.events) == 1
- event = self.raven.events.pop(0)
-
- assert event['culprit'].startswith('django.shortcuts in ')
- self.raven.include_paths = include_paths
def test_template_name_as_view(self):
self.assertRaises(TemplateSyntaxError, self.client.get, reverse('sentry-template-exc'))
diff --git a/tests/contrib/flask/tests.py b/tests/contrib/flask/tests.py
index f66e34a..aa51f41 100644
--- a/tests/contrib/flask/tests.py
+++ b/tests/contrib/flask/tests.py
@@ -113,7 +113,6 @@ class FlaskTest(BaseTest):
self.assertEquals(exc['value'], 'hello world')
self.assertEquals(event['level'], logging.ERROR)
self.assertEquals(event['message'], 'ValueError: hello world')
- self.assertEquals(event['culprit'], 'tests.contrib.flask.tests in an_error')
def test_get(self):
response = self.client.get('/an-error/?foo=bar')
diff --git a/tests/contrib/webpy/tests.py b/tests/contrib/webpy/tests.py
index d96cb9c..7d63e50 100644
--- a/tests/contrib/webpy/tests.py
+++ b/tests/contrib/webpy/tests.py
@@ -57,7 +57,6 @@ class WebPyTest(TestCase):
self.assertEquals(exc['type'], 'ValueError')
self.assertEquals(exc['value'], 'That\'s what she said')
self.assertEquals(event['message'], 'ValueError: That\'s what she said')
- self.assertEquals(event['culprit'], 'tests.contrib.webpy.tests in GET')
def test_post(self):
response = self.client.post('/test?biz=baz', params={'foo': 'bar'}, expect_errors=True)
diff --git a/tests/handlers/logging/tests.py b/tests/handlers/logging/tests.py
index 239224e..f4a51c2 100644
--- a/tests/handlers/logging/tests.py
+++ b/tests/handlers/logging/tests.py
@@ -150,7 +150,6 @@ class LoggingIntegrationTest(TestCase):
self.assertEqual(frame['module'], 'raven.handlers.logging')
assert 'exception' not in event
self.assertTrue('sentry.interfaces.Message' in event)
- self.assertEqual(event['culprit'], 'root in make_record')
self.assertEqual(event['message'], 'This is a test of stacks')
def test_no_record_stack(self):
@@ -169,8 +168,6 @@ class LoggingIntegrationTest(TestCase):
self.assertEqual(len(self.client.events), 1)
event = self.client.events.pop(0)
assert 'stacktrace' in event
- assert 'culprit' in event
- assert event['culprit'] == 'root in make_record'
self.assertTrue('message' in event, event)
self.assertEqual(event['message'], 'This is a test of stacks')
assert 'exception' not in event
diff --git a/tests/utils/stacks/tests.py b/tests/utils/stacks/tests.py
index 8ae22c4..7d844b1 100644
--- a/tests/utils/stacks/tests.py
+++ b/tests/utils/stacks/tests.py
@@ -5,7 +5,7 @@ from mock import Mock
from raven.utils.testutils import TestCase
from raven.utils import six
-from raven.utils.stacks import get_culprit, get_stack_info, get_lines_from_file
+from raven.utils.stacks import get_stack_info, get_lines_from_file
class Context(object):
@@ -17,33 +17,6 @@ class Context(object):
iterkeys = lambda s, *a: six.iterkeys(s.dict, *a)
-class GetCulpritTest(TestCase):
- def test_empty_module(self):
- culprit = get_culprit([{
- 'module': None,
- 'function': 'foo',
- }])
- assert culprit == '? in foo'
-
- def test_empty_function(self):
- culprit = get_culprit([{
- 'module': 'foo',
- 'function': None,
- }])
- assert culprit == 'foo in ?'
-
- def test_no_module_or_function(self):
- culprit = get_culprit([{}])
- assert culprit is None
-
- def test_all_params(self):
- culprit = get_culprit([{
- 'module': 'package.name',
- 'function': 'foo',
- }])
- assert culprit == 'package.name in foo'
-
-
class GetStackInfoTest(TestCase):
def test_bad_locals_in_frame(self):
frame = Mock()