opentracing-contrib/python-django

OPENTRACING_TRACED_ATTRIBUTES passed as a tuple of a list

Closed this issue · 1 comments

Right now I have
OPENTRACING_TRACED_ATTRIBUTES = ['path', 'method']

Which fails with the error:

Traceback (most recent call last):
  File "/home/parallels/hv4/hv/venv/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/parallels/hv4/hv/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/home/parallels/hv4/hv/venv/local/lib/python2.7/site-packages/django_opentracing/middleware.py", line 36, in process_view
    self._tracer._apply_tracing(request, view_func, traced_attributes)
  File "/home/parallels/hv4/hv/venv/local/lib/python2.7/site-packages/django_opentracing/tracer.py", line 89, in _apply_tracing
    if hasattr(request, attr):
TypeError: hasattr(): attribute name must be string

It appears that OPENTRACING_TRACED_ATTRIBUTES is being passed as a tuple with the list inside of it.

So when django_opentracing/tracer.py:88 calls for attr in attributes: attr will be a list instead of a string. Here is a screen cap from my debugger.
screen shot 2018-07-20 at 1 51 22 pm

I messed up, apologies. Somehow a trailing comma got in there and tricked Python into thinking it was a tuple. I bring dishonor to my family.