def test_enrich_span_basic_values() -> None: channel = mock.MagicMock() properties = mock.MagicMock() task_destination = "test.test" span = mock.MagicMock(spec=Span) utils._enrich_span(span, channel, properties, task_destination) span.set_attribute.assert_has_calls( any_order=True, calls=[ mock.call(SpanAttributes.MESSAGING_SYSTEM, "rabbitmq"), mock.call(SpanAttributes.MESSAGING_TEMP_DESTINATION, True), mock.call( SpanAttributes.MESSAGING_DESTINATION, task_destination ), mock.call( SpanAttributes.MESSAGING_MESSAGE_ID, properties.message_id ), mock.call( SpanAttributes.MESSAGING_CONVERSATION_ID, properties.correlation_id, ), mock.call( SpanAttributes.NET_PEER_NAME, channel.connection.params.host, ), mock.call( SpanAttributes.NET_PEER_PORT, channel.connection.params.port, ), ], )
def test_enrich_span_without_operation() -> None: channel = mock.MagicMock() properties = mock.MagicMock() task_destination = "test.test" span = mock.MagicMock(spec=Span) utils._enrich_span(span, channel, properties, task_destination) span.set_attribute.assert_has_calls( any_order=True, calls=[mock.call(SpanAttributes.MESSAGING_TEMP_DESTINATION, True)], )
def test_enrich_span_unique_connection() -> None: channel = mock.MagicMock() properties = mock.MagicMock() task_destination = "test.test" span = mock.MagicMock(spec=Span) # We do this to create the behaviour of hasattr(channel.connection, "params") == False del channel.connection.params utils._enrich_span(span, channel, properties, task_destination) span.set_attribute.assert_has_calls( any_order=True, calls=[ mock.call( SpanAttributes.NET_PEER_NAME, channel.connection._impl.params.host, ), mock.call( SpanAttributes.NET_PEER_PORT, channel.connection._impl.params.port, ), ], )