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

feat: Add path parameter rendering feature #2879

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jagerzhang
Copy link

@jagerzhang jagerzhang commented Sep 23, 2024

Description

In the current version, path parameters are not rendered properly in the span name (e.g., GET /api/{userId}), leading to confusion for users who expect to see the relevant path information. This issue particularly affects scenarios where dynamic paths are generated.

To address this, a new optional boolean parameter, render_path_parameters, has been added to enable or disable the rendering of path parameters in the span name:

otel_fastapi.FastAPIInstrumentor().instrument_app(app, render_path_parameters=True)

With this change, the spanName GET /api/{userId} will be recorded as GET /api/123456.

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [* ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested?

Unit tests have been added to ensure that path parameters render correctly in different scenarios.

  • [*] TestFastAPIRenderPathParameters in ’tests/test_fastapi_instrumentation.py`

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

Copy link

linux-foundation-easycla bot commented Sep 23, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

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.

1 participant