Skip to content

fix(instrumentation-pika): update span attributes to current messaging semconv#4654

Open
stark256-spec wants to merge 1 commit into
open-telemetry:mainfrom
stark256-spec:fix/pika-semconv-attributes
Open

fix(instrumentation-pika): update span attributes to current messaging semconv#4654
stark256-spec wants to merge 1 commit into
open-telemetry:mainfrom
stark256-spec:fix/pika-semconv-attributes

Conversation

@stark256-spec

Copy link
Copy Markdown

Description

Updates the pika instrumentation to use the current OpenTelemetry messaging semantic conventions, replacing deprecated constants throughout utils.py.

Fixes #1643

Attribute mapping

Old (deprecated) New
SpanAttributes.MESSAGING_SYSTEM MESSAGING_SYSTEM (messaging_attributes)
SpanAttributes.MESSAGING_OPERATION (messaging.operation) MESSAGING_OPERATION_TYPE (messaging.operation.type)
SpanAttributes.MESSAGING_TEMP_DESTINATION MESSAGING_DESTINATION_TEMPORARY
SpanAttributes.MESSAGING_DESTINATION MESSAGING_DESTINATION_NAME
SpanAttributes.MESSAGING_MESSAGE_ID MESSAGING_MESSAGE_ID
SpanAttributes.MESSAGING_CONVERSATION_ID MESSAGING_MESSAGE_CONVERSATION_ID
NET_PEER_NAME (net.peer.name) SERVER_ADDRESS (server.address)
NET_PEER_PORT (net.peer.port) SERVER_PORT (server.port)
MessagingOperationValues.RECEIVE MessagingOperationTypeValues.RECEIVE

Also adds two RabbitMQ-specific attributes that were missing:

  • messaging.rabbitmq.destination.routing_key — set on both producer and consumer spans when a routing key is present
  • messaging.rabbitmq.message.delivery_tag — set on consumer spans from method.delivery_tag

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • All 19 existing unit tests in tests/test_utils.py updated to assert the new attribute names and values; all pass.
  • Two new tests added: test_enrich_span_with_routing_key and test_enrich_span_with_delivery_tag.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

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

…g semconv

Replaces deprecated attribute constants from opentelemetry.semconv.trace and
net_attributes with the current incubating messaging_attributes equivalents,
and net peer attributes with server_attributes:

- messaging.system        (SpanAttributes → MESSAGING_SYSTEM)
- messaging.operation     → messaging.operation.type (MESSAGING_OPERATION_TYPE)
- messaging.temp_destination → messaging.destination.temporary
- messaging.destination   → messaging.destination.name
- messaging.message_id    → messaging.message.id
- messaging.conversation_id → messaging.message.conversation_id
- net.peer.name           → server.address
- net.peer.port           → server.port

Also adds two RabbitMQ-specific attributes now present in the spec:
- messaging.rabbitmq.destination.routing_key (threaded through from method)
- messaging.rabbitmq.message.delivery_tag    (threaded through from method)

MessagingOperationValues.RECEIVE replaced with MessagingOperationTypeValues.RECEIVE
throughout. All 19 unit tests updated and passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Make sure pika instrumentation follows semantic conventions

1 participant