Skip to content

refactor: semcov opentelemetry instrumentation aio pika #3667

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 8 commits into
base: main
Choose a base branch
from

Conversation

EzzioMoreira
Copy link
Contributor

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))

Fixes: #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
@emdneto emdneto added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Aug 5, 2025
if properties.correlation_id:
self._attributes[SpanAttributes.MESSAGING_CONVERSATION_ID] = (
self._attributes[MESSAGING_MESSAGE_CONVERSATION_ID] = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a different attribute

Copy link
Member

@emdneto emdneto Aug 12, 2025

Choose a reason for hiding this comment

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

oh, that's true. missed that @EzzioMoreira can you fix that?

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.

Stop using SpanAttributes
3 participants