Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

TypeError when used with django statsd #354

Closed
jeromer opened this Issue · 1 comment

2 participants

@jeromer

When I use the toolbar and django statsd I get the following StackTrace:

Traceback:
File "/home/website/pyenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  188.                 response = middleware_method(request, response)
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/middleware.py" in process_response
  169.                 self.view_name,
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/middleware.py" in stop
  156.             cls.scope.timings.submit(*key)
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/middleware.py" in submit
  92.         client = self.get_client(*args)
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/middleware.py" in get_client
  47.         return utils.get_client(prefix, class_=self.class_)
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/utils.py" in get_client
  18.         connection = get_connection()
File "/home/website/pyenv/lib/python2.7/site-packages/django_statsd/utils.py" in get_connection
  14.     return statsd.Connection(host, port, sample_rate)
File "/home/website/pyenv/lib/python2.7/site-packages/statsd/connection.py" in __init__
  36.             self._host, self._port, self._sample_rate)
File "/usr/lib/python2.7/logging/__init__.py" in debug
  1136.             self._log(DEBUG, msg, args, **kwargs)
File "/usr/lib/python2.7/logging/__init__.py" in _log
  1267.         self.handle(record)
File "/usr/lib/python2.7/logging/__init__.py" in handle
  1277.             self.callHandlers(record)
File "/usr/lib/python2.7/logging/__init__.py" in callHandlers
  1317.                     hdlr.handle(record)
File "/usr/lib/python2.7/logging/__init__.py" in handle
  748.                 self.emit(record)
File "/home/website/pyenv/lib/python2.7/site-packages/debug_toolbar/panels/logger.py" in emit
  51.             'message': record.getMessage(),
File "/usr/lib/python2.7/logging/__init__.py" in getMessage
  328.             msg = msg % self.args

Exception Type: TypeError at /
Exception Value: float argument required, not str

I tried to reorder middleware declarations but it changes nothing.

The only "fix" I found is to disable debug_toolbar.panels.logger.LoggingPanel.

The problem seems to appear when used with Apache mod_wsgi. I do not get this TypeError when running ./manage.py --runserver.

Environnement:

  • Linux,
  • Python 2.7.3,
  • Django 1.4.3
  • python-statsd==1.5.7
  • django-debug-toolbar==0.9.4
  • Apache mod_wsgi
@aaugustin
Owner

Looking at the stack trace, this appears to be a bug in django_statsd.

To confirm, I'd need the value of the record argument passed to ThreadTrackingHandler.emit just before the crash happens.

@aaugustin aaugustin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.