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

Provide a public Django middleware class

Open
#2,301 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem?
We would to have control over what position django middleware gets placed in the chain. Currently the instrument() method inserts it at the head. In our case we would like to have exception tracking middleware (Rollbar) execute before tracing middleware.

Describe the solution you'd like
A public Django middleware class that can be configured in settings like so:

MIDDLEWARE = (
  "middleware.ExceptionTrackingMiddleware", 
  "opentelemetry.instrumentation.django.DjangoMiddleware",
)

Describe alternatives you've considered

  • Modifying middleware chain at runtime (this seems dangerous)
  • Wrapping the private middleware class (also seems dangerous)

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 by tracing the instrument() method and the private Django middleware class, then compare their behavior with Django's MIDDLEWARE settings. The work is done when a public opentelemetry.instrumentation.django.DjangoMiddleware can be configured in the middleware chain and allows exception tracking middleware to run before tracing middleware.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.