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 transaction names for starlette Mount routes #1037

Merged
merged 9 commits into from
Feb 19, 2021
Merged

Fix transaction names for starlette Mount routes #1037

merged 9 commits into from
Feb 19, 2021

Conversation

pypae
Copy link
Contributor

@pypae pypae commented Feb 3, 2021

What does this pull request do?

Fix transaction names for starlette Mount routes.
Recursively build route names for mounted sub-applications.

Related issues

closes #1036

Note: Opened it as a draft pull request because I couldn't write tests yet, but I still wanted to give you an idea of a potential fix.

@cla-checker-service
Copy link

cla-checker-service bot commented Feb 3, 2021

💚 CLA has been signed

@apmmachine
Copy link
Contributor

apmmachine commented Feb 3, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #1037 updated

  • Start Time: 2021-02-19T18:54:22.296+0000

  • Duration: 21 min 15 sec

  • Commit: 06c6d75

Test stats 🧪

Test Results
Failed 0
Passed 7947
Skipped 5735
Total 13682

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 7947
Skipped 5735
Total 13682

@beniwohli
Copy link
Contributor

@pypae great work on the fix! I had a look at the issue that you opened yesterday and came to the same conclusion that a recursive approach is probably the cleanest. I don't expect these hierarchies of mounts to become very deep, so the overhead of recursion over an iterative approach should be fairly small.

I took the liberty to push a test I wrote yesterday to confirm the issue to your branch.

@pypae pypae marked this pull request as ready for review February 5, 2021 08:08
Copy link
Contributor

@beniwohli beniwohli left a comment

Choose a reason for hiding this comment

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

Great work, thanks!

@pypae
Copy link
Contributor Author

pypae commented Feb 5, 2021

I just realized that naming for trailing slash redirects does not work correctly with sub-applications.
On another note: Are you okay with the nested and untyped function _get_route_name, or should I move it?

Thank you for this awesome project by the way.

@basepi
Copy link
Contributor

basepi commented Feb 5, 2021

Are you okay with the nested and untyped function _get_route_name, or should I move it?

I don't necessarily have a problem with it, but since it's not a closure it would probably be cleaner to make it a separate method.

@basepi basepi merged commit a5e6660 into elastic:master Feb 19, 2021
beniwohli added a commit to beniwohli/apm-agent-python that referenced this pull request Sep 14, 2021
* Fix transaction names for mounted routes

* add test for mounted apps

* fix too many blank lines

* Add test for trailing slash redirects with sub-applications

* Fix trailing slash redirect for sub-applications

* Pull out recursive _get_route_name (+Changelog)

Co-authored-by: Benjamin Wohlwend <beni@elastic.co>
Co-authored-by: Colton Myers <colton.myers@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inaccurate transaction names for FastAPI sub-applications
5 participants