open-telemetry / open-telemetry/opentelemetry-python-contrib

Django instrumentation assumes ASGI is only for Django3+

Open
#1,416 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.1k
Forks
1.1k
Avg merge
4d 15h
Merged PRs (30d)
16

Description

Describe your environment

My code is on Django 2.x. And I run into https://github.com/open-telemetry/opentelemetry-python/issues/2833
Debugging down shows that the _is_asgi_request() in otel_middleware.py is thus determining that a request can't be an ASGI request.

Steps to reproduce

Just look at the code. Also when you continue and set is_asgi_request to True manually, my code works as expected

What is the expected behavior?

Just use ASGi and don't run into #2833

What is the actual behavior?

Run into #2833 as even valid ASGi requests are treated like WSGi ones, which then fails.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in otel_middleware.py at _is_asgi_request() and compare its Django-version assumption with the Django 2.x environment described. Reproduce the behavior from the issue and verify that valid ASGI requests are treated as ASGI rather than WSGI, avoiding the failure in issue #2833.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.