Skip to content

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

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))

Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ def extract_attributes(
] = 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"
)
Original file line number Diff line number Diff line change
@@ -118,6 +118,12 @@ def _test_publish_to_arn(self, arg_name: str):
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 @@ def test_publish_batch_to_topic(self):
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)