dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

fix(flask): response streaming

Open mabdinur opened this issue 3 years ago • 3 comments

Description

  • Blocked by: https://github.com/DataDog/dd-trace-py/pull/4303

  • Use ddtrace wsgi middleware to trace flask applications. This ensures flask responses are traced and it's duration is captured in the flask.request span.

  • Update flask test client to close response. This ensures the request and response spans are finished.

  • Adds test case for response streaming in flask

  • Update flask snapshots and tests to include flask.application and flask.response spans

Checklist

Motivation

Design

Testing strategy

Relevant issue(s)

Testing strategy

Reviewer Checklist

  • [ ] Title is accurate.
  • [ ] Description motivates each change.
  • [ ] No unnecessary changes were introduced in this PR.
  • [ ] PR cannot be broken up into smaller PRs.
  • [ ] Avoid breaking API changes unless absolutely necessary.
  • [ ] Tests provided or description of manual testing performed is included in the code or PR.
  • [ ] Release note has been added for fixes and features, or else changelog/no-changelog label added.
  • [ ] All relevant GitHub issues are correctly linked.
  • [ ] Backports are identified and tagged with Mergifyio.
  • [ ] Add to milestone.

mabdinur avatar Sep 16 '22 21:09 mabdinur

Using a generator function raised session issues in SQLAlchemy.

@mabdinur can you include the relevant exception and traceback?

majorgreys avatar Sep 19 '22 18:09 majorgreys

Codecov Report

Merging #4202 (0bbfbbc) into 1.x (fdcefa9) will decrease coverage by 0.04%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##              1.x    #4202      +/-   ##
==========================================
- Coverage   77.97%   77.92%   -0.05%     
==========================================
  Files         760      760              
  Lines       60288    60319      +31     
==========================================
- Hits        47007    47006       -1     
- Misses      13281    13313      +32     
Impacted Files Coverage Δ
ddtrace/contrib/flask/patch.py 0.00% <0.00%> (ø)
tests/contrib/flask/__init__.py 0.00% <0.00%> (ø)
tests/contrib/flask/test_hooks.py 0.00% <0.00%> (ø)
tests/contrib/flask/test_request.py 0.00% <0.00%> (ø)
tests/contrib/flask/test_static.py 0.00% <0.00%> (ø)
...ts/contrib/flask_autopatch/test_flask_autopatch.py 0.00% <0.00%> (ø)
tests/utils.py 90.35% <0.00%> (-0.24%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 19 '22 19:09 codecov-commenter

@mabdinur this pull request is now in conflict 😩

mergify[bot] avatar Oct 11 '22 16:10 mergify[bot]

backport 1.5 1.6

✅ Backports have been created

mergify[bot] avatar Nov 03 '22 14:11 mergify[bot]

@mabdinur this pull request is now in conflict 😩

mergify[bot] avatar Nov 04 '22 16:11 mergify[bot]

It might be nice to see the same request flamegraph before and after for reference, but looking at the snapshots you can figure it out so just a nit.

ZStriker19 avatar Nov 14 '22 22:11 ZStriker19

@mabdinur this pull request is now in conflict 😩

mergify[bot] avatar Nov 17 '22 13:11 mergify[bot]

@mabdinur this pull request is now in conflict 😩

mergify[bot] avatar Nov 23 '22 20:11 mergify[bot]

We should check the flask-poc system tests job to make sure we didn't break that. It looks like all the system tests jobs are failing though.

Kyle-Verhoog avatar Nov 23 '22 21:11 Kyle-Verhoog