-
Couldn't load subscription status.
- Fork 801
Use canonical name for aiohttp request span name #3896
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
base: main
Are you sure you want to change the base?
Conversation
|
|
02658f3 to
1ba9a1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks a lot for the effort! 👍🏻
| for request_path, span in zip( | ||
| example_paths, memory_exporter.get_finished_spans() | ||
| ): | ||
| assert url == span.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
| a tuple of the span name, and any attributes to attach to the span. | ||
| """ | ||
| span_name = request.path.strip() or f"HTTP {request.method}" | ||
| if request.match_info and request.match_info.route.resource: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is match_info.route guaranteed to be not None when match_info is not None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the good point. i think this can be the proof: https://github.com/aio-libs/aiohttp/blob/master/aiohttp/web_urldispatcher.py#L231
(in fact, even match_info can't be None: https://github.com/aio-libs/aiohttp/blob/v3.13.1/aiohttp/web_request.py#L890 but it may raise issues with type hints)
Description
Current implementation doesn't use canonical attribute of a
Resource, which leads to the situation when generated spans all have unique names. It creates high cardinality of spans. Other frameworks that use path params create spans with "canonical" paths in names (e.g. fastapi [1] )Type of change
How Has This Been Tested?
add a new unit test:
test_url_params_instrumentationDoes This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.