Skip to content

Conversation

@krnr
Copy link
Contributor

@krnr krnr commented Oct 25, 2025

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

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

add a new unit test:

  • test_url_params_instrumentation

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@krnr krnr requested a review from a team as a code owner October 25, 2025 05:15
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 25, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: krnr / name: krnr (8689cfc)

@krnr krnr force-pushed the main branch 4 times, most recently from 02658f3 to 1ba9a1c Compare October 25, 2025 05:24
Copy link

@bisgaard-itis bisgaard-itis left a 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

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:

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?

Copy link
Contributor Author

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)

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