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

fix(starlette): fixes incorrect handling of path/root_path in older starlette versions #8613

Closed
wants to merge 2 commits into from

Conversation

zarirhamza
Copy link
Contributor

root_path now correctly contains the duplicated mounted path found in path for starlette > v0.34 as per ASGI standards

Previously, there was no duplication when mounting applications on starlette. This required us to set tags using both root_path and path. However, this was later fixed in later versions of starlette leading to duplication.

Logic is now implemented such that the ASGI middleware follows the specifications and only takes the path into consideration for tracing and older versions of starlette have their spans edited within the starlette integration

Changes are also made to the testing snapshots to account for the TestClient change after v0.20 in starlette

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.
  • If change touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

Comment on lines +171 to +172
# If we are on a version of starlette that is less than 0.34, we need to fix the span url
# since starlette sets the incorrect values for path/root_path
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we link to the starlette issue here. This will make this problem easier to track

Suggested change
# If we are on a version of starlette that is less than 0.34, we need to fix the span url
# since starlette sets the incorrect values for path/root_path
# If we are on a version of starlette that is less than 0.34, we need to fix the span url
# since starlette sets the incorrect values for path/root_path

@datadog-dd-trace-py-rkomorn
Copy link

Datadog Report

Branch report: zarir/starlette-fix-and-upgrade
Commit report: d3eec4b
Test service: dd-trace-py

✅ 0 Failed, 171103 Passed, 1038 Skipped, 11h 35m 10.04s Total duration (15m 0.11s time saved)

@zarirhamza zarirhamza closed this Mar 6, 2024
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.

2 participants