Skip to content
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

Add SNS support. #197

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Use Topic instead of TopicArn.
  • Loading branch information
zzhlogin committed May 30, 2024
commit b0fec2ea346085f2687915cd9965e16677c33d34
Original file line number Diff line number Diff line change
@@ -375,7 +375,7 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
SqsUrlParser.get_queue_name(span.attributes.get(AWS_QUEUE_URL))
)
elif is_key_present(span, AWS_TOPIC_ARN):
remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::TopicArn"
remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::Topic"
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_TOPIC_ARN))
elif is_db_span(span):
remote_resource_type = _DB_CONNECTION_STRING_TYPE
Original file line number Diff line number Diff line change
@@ -981,7 +981,7 @@ def test_sdk_client_span_with_remote_resource_attributes(self):

# Validate behaviour of AWS_TOPIC_ARN attribute, then remove it
self._mock_attribute([AWS_TOPIC_ARN], ["arn:aws:sns:us-west-2:012345678901:test_topic"], keys, values)
self._validate_remote_resource_attributes("AWS::SNS::TopicArn", "arn:aws:sns:us-west-2:012345678901:test_topic")
self._validate_remote_resource_attributes("AWS::SNS::Topic", "arn:aws:sns:us-west-2:012345678901:test_topic")
self._mock_attribute([AWS_TOPIC_ARN], [None])

self._mock_attribute([SpanAttributes.RPC_SYSTEM], [None])
Original file line number Diff line number Diff line change
@@ -80,6 +80,8 @@ def _validate_unpatched_botocore_instrumentation(self):
self.assertTrue("sns" in _KNOWN_EXTENSIONS, "Upstream has removed the SNS extension")
sns_attributes: Dict[str, str] = _do_extract_sns_attributes()
self.assertFalse("aws.sns.topic_arn" in sns_attributes)
sns_success_attributes: Dict[str, str] = _do_sns_on_success()
self.assertFlase("aws.sns.topic_arn" in sns_success_attributes)

def _validate_patched_botocore_instrumentation(self):
# Kinesis
8 changes: 4 additions & 4 deletions contract-tests/tests/test/amazon/botocore/botocore_test.py
Original file line number Diff line number Diff line change
@@ -398,7 +398,7 @@ def test_sns_get_topic_attributes(self):
0,
remote_service="AWS::SNS",
remote_operation="GetTopicAttributes",
remote_resource_type="AWS::SNS::TopicArn",
remote_resource_type="AWS::SNS::Topic",
remote_resource_identifier="arn:aws:sns:us-west-2:000000000000:test_topic",
request_specific_attributes={
_AWS_TOPIC_ARN: "arn:aws:sns:us-west-2:000000000000:test_topic",
@@ -416,7 +416,7 @@ def test_sns_publish_message(self):
0,
remote_service="AWS::SNS",
remote_operation="Publish",
remote_resource_type="AWS::SNS::TopicArn",
remote_resource_type="AWS::SNS::Topic",
remote_resource_identifier="arn:aws:sns:us-west-2:000000000000:test_topic",
request_specific_attributes={
_AWS_TOPIC_ARN: "arn:aws:sns:us-west-2:000000000000:test_topic",
@@ -434,7 +434,7 @@ def test_sns_error(self):
0,
remote_service="AWS::SNS",
remote_operation="Publish",
remote_resource_type="AWS::SNS::TopicArn",
remote_resource_type="AWS::SNS::Topic",
remote_resource_identifier="arn:aws:sns:us-west-2:000000000000:test_topic/snserror",
request_specific_attributes={
_AWS_TOPIC_ARN: "arn:aws:sns:us-west-2:000000000000:test_topic/snserror",
@@ -452,7 +452,7 @@ def test_sns_fault(self):
1,
remote_service="AWS::SNS",
remote_operation="GetTopicAttributes",
remote_resource_type="AWS::SNS::TopicArn",
remote_resource_type="AWS::SNS::Topic",
remote_resource_identifier="invalid_topic_arn",
request_specific_attributes={
_AWS_TOPIC_ARN: "invalid_topic_arn",