1616 AWS_LOCAL_OPERATION ,
1717 AWS_LOCAL_SERVICE ,
1818 AWS_REMOTE_OPERATION ,
19+ AWS_REMOTE_RESOURCE_ACCESS_KEY ,
20+ AWS_REMOTE_RESOURCE_ACCOUNT_ID ,
1921 AWS_REMOTE_RESOURCE_IDENTIFIER ,
22+ AWS_REMOTE_RESOURCE_REGION ,
2023 AWS_REMOTE_RESOURCE_TYPE ,
2124 AWS_REMOTE_SERVICE ,
2225 AWS_SPAN_KIND ,
5053_AWS_STATE_MACHINE_ARN : str = "aws.stepfunctions.state_machine.arn"
5154_AWS_ACTIVITY_ARN : str = "aws.stepfunctions.activity.arn"
5255_AWS_SNS_TOPIC_ARN : str = "aws.sns.topic.arn"
56+ _AWS_DYNAMODB_TABLE_ARN : str = "aws.dynamodb.table.arn"
57+ _AWS_KINESIS_STREAM_ARN : str = "aws.kinesis.stream.arn"
5358
5459
5560# pylint: disable=too-many-public-methods,too-many-lines
@@ -212,6 +217,29 @@ def test_dynamodb_create_table(self):
212217 span_name = "DynamoDB.CreateTable" ,
213218 )
214219
220+ def test_dynamodb_describe_table (self ):
221+ self .do_test_requests (
222+ "ddb/describetable/some-table" ,
223+ "GET" ,
224+ 200 ,
225+ 0 ,
226+ 0 ,
227+ remote_service = "AWS::DynamoDB" ,
228+ remote_operation = "DescribeTable" ,
229+ remote_resource_type = "AWS::DynamoDB::Table" ,
230+ remote_resource_identifier = "put_test_table" ,
231+ remote_resource_account_id = "000000000000" ,
232+ remote_resource_region = "us-west-2" ,
233+ cloudformation_primary_identifier = "put_test_table" ,
234+ request_specific_attributes = {
235+ SpanAttributes .AWS_DYNAMODB_TABLE_NAMES : ["put_test_table" ],
236+ },
237+ response_specific_attributes = {
238+ _AWS_DYNAMODB_TABLE_ARN : r"arn:aws:dynamodb:us-west-2:000000000000:table/put_test_table" ,
239+ },
240+ span_name = "DynamoDB.DescribeTable" ,
241+ )
242+
215243 def test_dynamodb_put_item (self ):
216244 self .do_test_requests (
217245 "ddb/putitem/putitem-table/key" ,
@@ -379,6 +407,26 @@ def test_kinesis_put_record(self):
379407 span_name = "Kinesis.PutRecord" ,
380408 )
381409
410+ def test_kinesis_describe_stream (self ):
411+ self .do_test_requests (
412+ "kinesis/describestream/my-stream" ,
413+ "GET" ,
414+ 200 ,
415+ 0 ,
416+ 0 ,
417+ remote_service = "AWS::Kinesis" ,
418+ remote_operation = "DescribeStream" ,
419+ remote_resource_type = "AWS::Kinesis::Stream" ,
420+ remote_resource_identifier = "test_stream" ,
421+ cloudformation_primary_identifier = "test_stream" ,
422+ remote_resource_account_id = "000000000000" ,
423+ remote_resource_region = "us-west-2" ,
424+ request_specific_attributes = {
425+ _AWS_KINESIS_STREAM_NAME : "test_stream" ,
426+ },
427+ span_name = "Kinesis.DescribeStream" ,
428+ )
429+
382430 def test_kinesis_error (self ):
383431 self .do_test_requests (
384432 "kinesis/error" ,
@@ -878,6 +926,26 @@ def test_stepfunctions_fault(self):
878926 span_name = "SFN.ListStateMachineVersions" ,
879927 )
880928
929+ def test_cross_account (self ):
930+ self .do_test_requests (
931+ "cross-account/createbucket/account_b" ,
932+ "GET" ,
933+ 200 ,
934+ 0 ,
935+ 0 ,
936+ remote_service = "AWS::S3" ,
937+ remote_operation = "CreateBucket" ,
938+ remote_resource_type = "AWS::S3::Bucket" ,
939+ remote_resource_identifier = "cross-account-bucket" ,
940+ cloudformation_primary_identifier = "cross-account-bucket" ,
941+ request_specific_attributes = {
942+ SpanAttributes .AWS_S3_BUCKET : "cross-account-bucket" ,
943+ },
944+ remote_resource_access_key = "account_b_access_key_id" ,
945+ remote_resource_region = "eu-central-1" ,
946+ span_name = "S3.CreateBucket" ,
947+ )
948+
881949 # TODO: Add contract test for lambda event source mapping resource
882950
883951 @override
@@ -897,6 +965,9 @@ def _assert_aws_span_attributes(self, resource_scope_spans: List[ResourceScopeSp
897965 kwargs .get ("remote_resource_type" , "None" ),
898966 kwargs .get ("remote_resource_identifier" , "None" ),
899967 kwargs .get ("cloudformation_primary_identifier" , "None" ),
968+ kwargs .get ("remote_resource_account_id" , "None" ),
969+ kwargs .get ("remote_resource_access_key" , "None" ),
970+ kwargs .get ("remote_resource_region" , "None" ),
900971 )
901972
902973 def _assert_aws_attributes (
@@ -908,6 +979,9 @@ def _assert_aws_attributes(
908979 remote_resource_type : str ,
909980 remote_resource_identifier : str ,
910981 cloudformation_primary_identifier : str ,
982+ remote_resource_account_id : str ,
983+ remote_resource_access_key : str ,
984+ remote_resource_region : str ,
911985 ) -> None :
912986 attributes_dict : Dict [str , AnyValue ] = self ._get_attributes_dict (attributes_list )
913987 self ._assert_str_attribute (attributes_dict , AWS_LOCAL_SERVICE , self .get_application_otel_service_name ())
@@ -934,8 +1008,16 @@ def _assert_aws_attributes(
9341008 self ._assert_str_attribute (
9351009 attributes_dict , AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER , cloudformation_primary_identifier
9361010 )
937- # See comment above AWS_LOCAL_OPERATION
938- self ._assert_str_attribute (attributes_dict , AWS_SPAN_KIND , span_kind )
1011+ if remote_resource_account_id != "None" :
1012+ assert remote_resource_identifier != "None"
1013+ self ._assert_str_attribute (attributes_dict , AWS_REMOTE_RESOURCE_ACCOUNT_ID , remote_resource_account_id )
1014+ self .assertIsNone (attributes_dict .get (AWS_REMOTE_RESOURCE_ACCESS_KEY ))
1015+ if remote_resource_access_key != "None" :
1016+ assert remote_resource_identifier != "None"
1017+ self ._assert_str_attribute (attributes_dict , AWS_REMOTE_RESOURCE_ACCESS_KEY , remote_resource_access_key )
1018+ self .assertIsNone (attributes_dict .get (AWS_REMOTE_RESOURCE_ACCOUNT_ID ))
1019+ if remote_resource_region != "None" :
1020+ self ._assert_str_attribute (attributes_dict , AWS_REMOTE_RESOURCE_REGION , remote_resource_region )
9391021
9401022 @override
9411023 def _assert_semantic_conventions_span_attributes (
@@ -1023,13 +1105,26 @@ def _assert_metric_attributes(
10231105 self ._assert_str_attribute (attribute_dict , AWS_SPAN_KIND , "CLIENT" )
10241106 remote_resource_type = kwargs .get ("remote_resource_type" , "None" )
10251107 remote_resource_identifier = kwargs .get ("remote_resource_identifier" , "None" )
1108+ remote_resource_account_id = kwargs .get ("remote_resource_account_id" , "None" )
1109+ remote_resource_access_key = kwargs .get ("remote_resource_access_key" , "None" )
1110+ remote_resource_region = kwargs .get ("remote_resource_region" , "None" )
10261111 if remote_resource_type != "None" :
10271112 self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_TYPE , remote_resource_type )
10281113 if remote_resource_identifier != "None" :
10291114 if self ._is_valid_regex (remote_resource_identifier ):
10301115 self ._assert_match_attribute (attribute_dict , AWS_REMOTE_RESOURCE_IDENTIFIER , remote_resource_identifier )
10311116 else :
10321117 self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_IDENTIFIER , remote_resource_identifier )
1118+ if remote_resource_account_id != "None" :
1119+ assert remote_resource_identifier != "None"
1120+ self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_ACCOUNT_ID , remote_resource_account_id )
1121+ self .assertIsNone (attribute_dict .get (AWS_REMOTE_RESOURCE_ACCESS_KEY ))
1122+ if remote_resource_access_key != "None" :
1123+ assert remote_resource_identifier != "None"
1124+ self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_ACCESS_KEY , remote_resource_access_key )
1125+ self .assertIsNone (attribute_dict .get (AWS_REMOTE_RESOURCE_ACCOUNT_ID ))
1126+ if remote_resource_region != "None" :
1127+ self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_REGION , remote_resource_region )
10331128 self .check_sum (metric_name , dependency_dp .sum , expected_sum )
10341129
10351130 attribute_dict : Dict [str , AnyValue ] = self ._get_attributes_dict (service_dp .attributes )
0 commit comments