You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(asgi, starlette, fastapi): exclude background task durations from web requests (#3799)
Following up on #3023, currently libraries traced via the `asgi` integration, such as`fastapi.request` and `starlette.request` spans include the duration of background tasks. This PR updates the asgi middleware code so that spans end earlier by excluding background tasks to better represent the web requests response times.
**Current Behavior**
$$\begin{align}duration = {http response time} + {background tasks time}\end{align}$$
**What it looks like with the PR**
$$\begin{align}duration = {http response time}\end{align}$$
**Example:** An application return a "hello world!" to the user in $2 milliseconds$, but the events that happen in the background lasts another $8 seconds$.
With this PR, the span will report a duration of $2 milliseconds$, instead of $2 milliseconds + 8 seconds$.
Fixes#3023
Also fixes this failing test: https://app.circleci.com/pipelines/github/DataDog/dd-trace-py/18150/workflows/24caa985-5805-4bff-a4eb-5b143f24a2fb/jobs/1233079
## Checklist
- [ ] Library documentation is updated.
- [ ] [Corp site](https://github.com/DataDog/documentation/) documentation is updated (link to the PR).
## 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](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) 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.
(cherry picked from commit 5b97489)
0 commit comments