Skip to content

refactor(flask): replace SpanAttributes with semconv attributes #3539

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

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

Conversation

artemziborev
Copy link
Contributor

@artemziborev artemziborev commented May 23, 2025

Description

This PR replaces deprecated usage of SpanAttributes with semantic convention attributes from opentelemetry.semconv.attributes in the opentelemetry-instrumentation-flask package.

These changes bring the Flask instrumentation module in line with current OpenTelemetry conventions and help modernize the codebase as part of the broader refactoring tracked in the issue below.

Refs #3475

Type of change

Please delete options that are not relevant.

  • 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?

  • Ran pytest for instrumentation/opentelemetry-instrumentation-flask/tests/
  • Verified that no references to SpanAttributes remain
  • Confirmed proper attribute output using updated semconv references

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [X ] No.

Checklist:

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

  • Followed the style guidelines of this project
  • Unit tests pass for this module

Copy link

linux-foundation-easycla bot commented May 23, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@artemziborev
Copy link
Contributor Author

Hi 👋 Just wanted to kindly follow up.

This PR replaces deprecated SpanAttributes usage in the Flask instrumentation with the recommended semantic convention attributes (http.method, http.route, etc.), as described in #3475.

All changes were tested locally and verified against the existing test suite. Please let me know if anything should be adjusted or improved — happy to iterate!

Thanks for your time and for maintaining this project 🙏

@xrmx xrmx added the Skip Changelog PRs that do not require a CHANGELOG.md entry label May 23, 2025
@@ -273,12 +273,14 @@ def response_hook(span: Span, status: str, response_headers: List):
)
from opentelemetry.instrumentation.utils import _start_internal_or_server_span
from opentelemetry.metrics import get_meter
from opentelemetry.semconv.attributes.http_attributes import HTTP_ROUTE
Copy link
Contributor

@xrmx xrmx May 23, 2025

Choose a reason for hiding this comment

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

I would keep using the stable one, no need to update the tests import to match

@xrmx xrmx self-requested a review May 27, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants