Skip to content

A subsequent exception is encountered when django instrumentation is handling the original exception #288

Open
@stschenk

Description

@stschenk

Describe your environment
opentelemetry-sdk==v0.16b1
opentelemetry-instrumentation==v0.16b1
opentelemetry-instrumentation-django==v0.16b1
opentelemetry-instrumentation-dbapi==v0.16b1
opentelemetry-instrumentation-requests==v0.16b1
opentelemetry-instrumentation-redis==v0.16b1
opentelemetry-instrumentation-celery==v0.16b1

Django==2.2.14

Note
This issue is not present when running Django-3.1.5. Things seem to work as expected.

Steps to reproduce
Make it so one of your views will always raise an Exception. Launch the server and then make a request to the views endpoint.

The raised exception will cause the following subsequent stack trace to occur:

Traceback (most recent call last):
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/stschenk/code/django-sandbox/mysite/polls/views.py", line 5, in index
    raise Exception()
Exception

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
TypeError: __call__() missing 1 required positional argument: 'func'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/views/debug.py", line 94, in technical_500_response
    html = reporter.get_traceback_html()
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/views/debug.py", line 334, in get_traceback_html
    return t.render(c)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/defaulttags.py", line 209, in render
    nodelist.append(node.render_annotated(context))
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 987, in render
    output = self.filter_expression.resolve(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 861, in _resolve_lookup
    getcallargs(current)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/inspect.py", line 1335, in getcallargs
    f_name = func.__name__
AttributeError: '_GeneratorContextManager' object has no attribute '__name__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 858, in _resolve_lookup
    current = current()
TypeError: __call__() missing 1 required positional argument: 'func'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/utils/deprecation.py", line 94, in __call__
    response = response or self.get_response(request)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner
    response = response_for_exception(request, exc)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/views/debug.py", line 94, in technical_500_response
    html = reporter.get_traceback_html()
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/views/debug.py", line 334, in get_traceback_html
    return t.render(c)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/defaulttags.py", line 309, in render
    return nodelist.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/defaulttags.py", line 209, in render
    nodelist.append(node.render_annotated(context))
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 987, in render
    output = self.filter_expression.resolve(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 671, in resolve
    obj = self.var.resolve(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 796, in resolve
    value = self._resolve_lookup(context)
  File "/Users/stschenk/.virtualenvs/django-sandbox/lib/python3.7/site-packages/django/template/base.py", line 861, in _resolve_lookup
    getcallargs(current)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/inspect.py", line 1335, in getcallargs
    f_name = func.__name__
AttributeError: '_GeneratorContextManager' object has no attribute '__name__'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions