Skip to content

Conversation

EzzioMoreira
Copy link
Contributor

@EzzioMoreira EzzioMoreira commented Jul 31, 2025

Description

A lot of code imports semantic conventions attributes from opentelemetry.semconv.trace.SpanAttributes instead of the preferred opentelemetry.semconv.attributes and opentelemetry.semconv.incubating.

This PR refactors the semantic conventions to use the new stable attribute modules instead of the deprecated SpanAttributes class.

Transition to New Semantic Conventions:

Attribute Updates in Instrumentation Code:

  • Replaced SpanAttributes with new _incubating attributes (e.g., MESSAGING_SYSTEM, NET_PEER_NAME) in span_builder.py for setting messaging and network-related attributes. ([[1]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-711c76942ba309cc5ba4848f1c882dced107f7827ac012939681e958b450e639R19-R36), [[2]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-711c76942ba309cc5ba4848f1c882dced107f7827ac012939681e958b450e639L47-R58), [[3]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-711c76942ba309cc5ba4848f1c882dced107f7827ac012939681e958b450e639L64-R95))

Updates in Test Files:

  • Updated test constants and expected attributes in test_callback_decorator.py and test_publish_decorator.py to use the new _incubating attributes. ([[1]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-96077bf1420276e86dafe08062f4484432064fb5730ae3b9b4786e828850a072L43-R59), [[2]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-500514cf8be14e4864fdf49daa4c761c0b1ad0c358cec84b4e26a2c62c1c5dffL47-R63))
  • Renamed MESSAGING_SYSTEM to MESSAGING_SYSTEM_VALUE in consts.py for consistency with the new conventions. ([instrumentation/opentelemetry-instrumentation-aio-pika/tests/consts.pyL9-R9](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-0f62be73cc5762de3b1f94f123557d7ec78c071062420d096243f79631197725L9-R9))

Helper Methods Refactor:

  • Refactored helper methods in _semconv.py to replace SpanAttributes with the corresponding _incubating attributes (e.g., HTTP_METHOD, NET_PEER_PORT). This ensures compatibility with the updated semantic conventions. ([[1]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-b3ec9cae86265a9c45bffb034e071516f6926ac72d702023bc9b52a7b49c4a90L290-R342), [[2]](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3667/files#diff-b3ec9cae86265a9c45bffb034e071516f6926ac72d702023bc9b52a7b49c4a90L368-R397))

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

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

@EzzioMoreira EzzioMoreira changed the title refactor/opentelemetry instrumentation aio pika refactor: semcov opentelemetry instrumentation aio pika Jul 31, 2025
@EzzioMoreira EzzioMoreira marked this pull request as ready for review July 31, 2025 22:48
@xrmx xrmx moved this to Easy to review / merge / close in @xrmx's Python PR digest Aug 4, 2025
@xrmx xrmx moved this from Easy to review / merge / close to Reviewed PR that needs fixing in @xrmx's Python PR digest Aug 4, 2025
@emdneto emdneto added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Aug 5, 2025
@xrmx xrmx enabled auto-merge (squash) September 9, 2025 15:12
@xrmx xrmx merged commit 67661d4 into open-telemetry:main Sep 9, 2025
632 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed PR that needs fixing to Done in @xrmx's Python PR digest Sep 9, 2025
chloe-zh97 pushed a commit to chloe-zh97/opentelemetry-python-contrib that referenced this pull request Sep 10, 2025
…ry#3667)

* feat: refactor semcov opentelemetry-instrumentation

* fix: return shema senconv

* refactor: opentelemetry-instrumentation-aio-pika

* fix: revert unintended changes to _semconv.py

* fix: change schema

* fix: change schema

* fix: spanattribute messaging id

* fix: spanattribute messaging id

---------

Co-authored-by: Emídio Neto <[email protected]>
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

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants