Specify the topic arn as the span attribute messaging.destination.name in the botocore sns instrumentation (#1995)

This commit is contained in:
Margaret Yu
2023-11-01 14:54:26 -07:00
committed by GitHub
parent 1305436671
commit 657d502419
3 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#1800](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1800))
### Added
- `opentelemetry-instrumentation-botocore` Include SNS topic ARN as a span attribute with name `messaging.destination.name` to uniquely identify the SNS topic
([#1995](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1995))
- `opentelemetry-instrumentation-system-metrics` Add support for collecting process metrics
([#1948](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1948))

View File

@ -81,6 +81,8 @@ class _OpPublish(_SnsOperation):
] = MessagingDestinationKindValues.TOPIC.value
attributes[SpanAttributes.MESSAGING_DESTINATION] = destination_name
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when opentelemetry-semantic-conventions 0.42b0 is released
attributes["messaging.destination.name"] = cls._extract_input_arn(call_context)
call_context.span_name = (
f"{'phone_number' if is_phone_number else destination_name} send"
)

View File

@ -118,6 +118,12 @@ class TestSnsExtension(TestBase):
self.topic_name,
span.attributes[SpanAttributes.MESSAGING_DESTINATION],
)
self.assertEqual(
target_arn,
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when
# opentelemetry-semantic-conventions 0.42b0 is released
span.attributes["messaging.destination.name"]
)
@mock_sns
def test_publish_to_phone_number(self):
@ -184,6 +190,12 @@ class TestSnsExtension(TestBase):
self.topic_name,
span.attributes[SpanAttributes.MESSAGING_DESTINATION],
)
self.assertEqual(
topic_arn,
# TODO: Use SpanAttributes.MESSAGING_DESTINATION_NAME when
# opentelemetry-semantic-conventions 0.42b0 is released
span.attributes["messaging.destination.name"]
)
self.assert_injected_span(message1_attrs, span)
self.assert_injected_span(message2_attrs, span)