Commit 9b5fdd0
flask: Clear context at the end of the request in non-streaming scenarios. (#4341)
* Initial plan
* Clean up _ENVIRON_ACTIVATION_KEY and _ENVIRON_TOKEN in _teardown_request to prevent duplicate execution
Add a finally block in _teardown_request to pop _ENVIRON_ACTIVATION_KEY and
_ENVIRON_TOKEN from flask.request.environ after teardown completes. This
prevents issues when _teardown_request is called multiple times, as the
second call will see activation as None and return early.
Co-authored-by: 123liuziming <32130965+123liuziming@users.noreply.github.com>
* Improve test to explicitly verify duplicate teardown calls don't cause errors
Co-authored-by: 123liuziming <32130965+123liuziming@users.noreply.github.com>
* fix lint
Change-Id: Iea7711d86dcd6f4da7a3af92cb68db2fe3db345f
Co-developed-by: Cursor <noreply@cursor.com>
* polish CHANGELOG
Change-Id: Ie89cac244ade8d04768503112db8673f91d81756
Co-developed-by: Cursor <noreply@cursor.com>
* Refactor request teardown to avoid duplicate cleanup
Remove redundant environment variable cleanup in finally block.
* Update test_flask_compatibility.py
* Uncomment FlaskInstrumentor import in test file
* Initial plan
* Fix ruff format errors in docker test files
Co-authored-by: 123liuziming <32130965+123liuziming@users.noreply.github.com>
Agent-Logs-Url: https://github.com/123liuziming/opentelemetry-python-contrib/sessions/9165702c-5648-474d-9291-dfa57008b0b6
* Initial plan
* Revert docker-test formatting changes that undo merged #4339 cleanup
Agent-Logs-Url: https://github.com/123liuziming/opentelemetry-python-contrib/sessions/25f73137-1606-4050-b879-ffc01d7ab803
Co-authored-by: 123liuziming <32130965+123liuziming@users.noreply.github.com>
* Update CHANGELOG.md
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>1 parent 0158026 commit 9b5fdd0
3 files changed
Lines changed: 62 additions & 0 deletions
File tree
- instrumentation/opentelemetry-instrumentation-flask
- src/opentelemetry/instrumentation/flask
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
| 639 | + | |
| 640 | + | |
639 | 641 | | |
640 | 642 | | |
641 | 643 | | |
| |||
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
354 | 356 | | |
355 | 357 | | |
356 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
0 commit comments