Skip to content

Fix DjangoInstrumentor exemplars generation for http.server.(request.)duration#3945

Merged
xrmx merged 16 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:fix-django-duration-exemplars
Dec 18, 2025
Merged

Fix DjangoInstrumentor exemplars generation for http.server.(request.)duration#3945
xrmx merged 16 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:fix-django-duration-exemplars

Conversation

@tammy-baylis-swi
Copy link
Copy Markdown
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Nov 14, 2025

Description

When exemplars are opted into via metrics SDK, this fixes DjangoInstrumentor middleware's generation of exemplars for http.server.request.duration and http.server.duration (new and old semconv respectively) so trace ID and span ID are no longer empty. Similar to Flask fix in #3912 -- test dep updates will conflict

Fixes #3951

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added unit tests
  • Added new Flask docker test
  • Installed changes to instrumented app

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • 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

@tammy-baylis-swi tammy-baylis-swi changed the title Fix FlaskInstrumentor exemplars generation for http.server.(request.)duration Fix DjangoInstrumentor exemplars generation for http.server.(request.)duration Nov 14, 2025
@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review November 17, 2025 19:41
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner November 17, 2025 19:41
@xrmx xrmx moved this to Ready for review in Python PR digest Nov 27, 2025
@xrmx xrmx moved this from Ready for review to Approved PRs in Python PR digest Nov 28, 2025
@xrmx xrmx enabled auto-merge (squash) December 5, 2025 16:33
@xrmx xrmx merged commit fd79ae9 into open-telemetry:main Dec 18, 2025
658 checks passed
@github-project-automation github-project-automation bot moved this from Approved PRs to Done in Python PR digest Dec 18, 2025
herin049 pushed a commit to herin049/opentelemetry-python-contrib that referenced this pull request Dec 22, 2025
…)duration (open-telemetry#3945)

* Add manual context recreation for Django duration exemplars

* Changelog

* Update unit test

* Add docker test_django_functional

* Deps

* Simpler metrics_context assignment

* Django activation exit after metrics record/add

* Add more asserts

* Rm first assn

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
RKest pushed a commit to RKest/opentelemetry-python-contrib that referenced this pull request Jan 12, 2026
…)duration (open-telemetry#3945)

* Add manual context recreation for Django duration exemplars

* Changelog

* Update unit test

* Add docker test_django_functional

* Deps

* Simpler metrics_context assignment

* Django activation exit after metrics record/add

* Add more asserts

* Rm first assn

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
sightseeker added a commit to sightseeker/opentelemetry-python-contrib that referenced this pull request Mar 11, 2026
…)duration (open-telemetry#3945)

* Add manual context recreation for Django duration exemplars

* Changelog

* Update unit test

* Add docker test_django_functional

* Deps

* Simpler metrics_context assignment

* Django activation exit after metrics record/add

* Add more asserts

* Rm first assn

* Update CHANGELOG.md

---------

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DjangoInstrumentor http.server.request.duration exemplars are missing span context

4 participants