disqus / django-perftools

Performance monitoring tools for Django
Apache License 2.0
110 stars 8 forks source link

Raven errors with django-perftools #4

Open vdboor opened 10 years ago

vdboor commented 10 years ago

I'm getting the following errors:

Top level Sentry exception caught - failed creating log record
Request exceeeded execution time threshold: %s
Traceback (most recent call last):
  File "/Users/diederik/Sites/virtualenvs/test26/lib/python2.6/site-packages/raven/handlers/logging.py", line 68, in emit
    return self._emit(record)
  File "/Users/diederik/Sites/virtualenvs/test26/lib/python2.6/site-packages/raven/contrib/django/handlers.py", line 29, in _emit
    return super(SentryHandler, self)._emit(record, request=request)
  File "/Users/diederik/Sites/virtualenvs/test26/lib/python2.6/site-packages/raven/handlers/logging.py", line 130, in _emit
    stack = self._get_targetted_stack(stack)
  File "/Users/diederik/Sites/virtualenvs/test26/lib/python2.6/site-packages/raven/handlers/logging.py", line 83, in _get_targetted_stack
    frame, lineno = item
ValueError: too many values to unpack

WARNING: Request exceeeded execution time threshold: http://127.0.0.1:8000/nl/admin/

This is my WSGI file:

from django.core.wsgi import get_wsgi_application
from raven.contrib.django.middleware.wsgi import Sentry
from perftools.middleware import SlowRequestLoggingMiddleware, QueryCountLoggingMiddleware

application = get_wsgi_application()
application = Sentry(application)
application = SlowRequestLoggingMiddleware(application, threshold=200) # in ms
application = QueryCountLoggingMiddleware(application, threshold=100)  # number of queries

I'm using:

Thanks in advance for any assistance or tips to solve this.

vdboor commented 10 years ago

Investigating it deeper, it seems that the error is triggered by the following extra={...} construct:

        self.logger.warning('Request exceeeded execution time threshold: %s', url, extra={
            'request': request,
            'view': culprit,
            'stack': frames,
            'url': url,
            'data': {
                'threshold': self.threshold,
            }
        })

When the stack argument value is simply True, the Raven error does not occur.

dcramer commented 10 years ago

@vdboor i believe the 'stack' value its passing is no longer in an acceptable format

vdboor commented 9 years ago

I'm a bit lost here. Would you be able to fix this?