Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django: Fix instrumentation and tests for all Django major versions #780

Merged
merged 6 commits into from
Oct 28, 2021

Conversation

adamantike
Copy link
Contributor

@adamantike adamantike commented Oct 26, 2021

Description

  • Fix support for Django 1.10/1.11, by allowing settings.MIDDLEWARE_CLASSES.
  • Add Tox environments for every Django major version, including 4.0 beta.
  • Fix tests for new Tox environments to pass.

Relevant context:

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • tox -e test-instrumentation-django{1,2,3,4}

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@adamantike adamantike requested a review from a team October 26, 2021 00:31
tox.ini Outdated
py3{6,7,8,9}-test-instrumentation-django
pypy3-test-instrumentation-django
py3{6,7,8,9}-test-instrumentation-django{1,2,3,4}
pypy3-test-instrumentation-django{1,2,3,4}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now but we should think if we can reduce the matrix size. May be test every single version on the oldest supported python version and then test only latest (or a random) version on every other python version. Concern is increased build times but this one change shouldn't make that much of a difference so no urgency yet.

Copy link
Contributor Author

@adamantike adamantike Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you mention it, we could at least reduce the amount of combination by testing only the officially supported Python version for each Django major release. That would end up in 4 removed test environments, considering that:

py3{6,7}-test-instrumentation-django1
py3{6,7,8,9}-test-instrumentation-django{2,3}
py3{8,9}-test-instrumentation-django4
pypy3-test-instrumentation-django{1,2,3,4}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pypy3 is currently based on Python 3.7, so it's not able to install Django 4.x.

Copy link
Contributor

@lzchen lzchen Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamantike
Could you add a comment inline to explain this reasoning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! I've added a note, let me know if it provides all the needed context.

* Fix support for Django `1.10`/`1.11`, by allowing `settings.MIDDLEWARE`.
* Add Tox environments for every Django major version, including 4.0 beta.
* Fix tests for new Tox environments to pass.

Relevant context:

* In Django 1.x, usage of `settings.MIDDLEWARE_CLASSES` is detected by
  running `settings.MIDDLEWARE is None`:
  https://github.com/django/django/blob/58f02c498b659a906e9c30d946bd89bedc4717e5/django/core/handlers/base.py#L48
* HTTP route in `ResolverMatch` object is only available since Django 2.2:
  django/django#10657
* Django class `HttpResponseBase` works as a mapping object, so avoiding
  accessing its internal headers object simplifies support accross
  Django versions.
@lzchen lzchen merged commit 9dc3bbb into open-telemetry:main Oct 28, 2021
nicholasgribanov pushed a commit to nicholasgribanov/opentelemetry-python-contrib that referenced this pull request Oct 29, 2021
nicholasgribanov pushed a commit to nicholasgribanov/opentelemetry-python-contrib that referenced this pull request Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants