16
16
AWS_LOCAL_OPERATION ,
17
17
AWS_LOCAL_SERVICE ,
18
18
AWS_REMOTE_OPERATION ,
19
+ AWS_REMOTE_RESOURCE_ACCESS_KEY ,
20
+ AWS_REMOTE_RESOURCE_ACCOUNT_ID ,
19
21
AWS_REMOTE_RESOURCE_IDENTIFIER ,
22
+ AWS_REMOTE_RESOURCE_REGION ,
20
23
AWS_REMOTE_RESOURCE_TYPE ,
21
24
AWS_REMOTE_SERVICE ,
22
25
AWS_SPAN_KIND ,
50
53
_AWS_STATE_MACHINE_ARN : str = "aws.stepfunctions.state_machine.arn"
51
54
_AWS_ACTIVITY_ARN : str = "aws.stepfunctions.activity.arn"
52
55
_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"
53
58
54
59
55
60
# pylint: disable=too-many-public-methods,too-many-lines
@@ -212,6 +217,29 @@ def test_dynamodb_create_table(self):
212
217
span_name = "DynamoDB.CreateTable" ,
213
218
)
214
219
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
+
215
243
def test_dynamodb_put_item (self ):
216
244
self .do_test_requests (
217
245
"ddb/putitem/putitem-table/key" ,
@@ -379,6 +407,26 @@ def test_kinesis_put_record(self):
379
407
span_name = "Kinesis.PutRecord" ,
380
408
)
381
409
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
+
382
430
def test_kinesis_error (self ):
383
431
self .do_test_requests (
384
432
"kinesis/error" ,
@@ -878,6 +926,26 @@ def test_stepfunctions_fault(self):
878
926
span_name = "SFN.ListStateMachineVersions" ,
879
927
)
880
928
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
+
881
949
# TODO: Add contract test for lambda event source mapping resource
882
950
883
951
@override
@@ -897,6 +965,9 @@ def _assert_aws_span_attributes(self, resource_scope_spans: List[ResourceScopeSp
897
965
kwargs .get ("remote_resource_type" , "None" ),
898
966
kwargs .get ("remote_resource_identifier" , "None" ),
899
967
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" ),
900
971
)
901
972
902
973
def _assert_aws_attributes (
@@ -908,6 +979,9 @@ def _assert_aws_attributes(
908
979
remote_resource_type : str ,
909
980
remote_resource_identifier : str ,
910
981
cloudformation_primary_identifier : str ,
982
+ remote_resource_account_id : str ,
983
+ remote_resource_access_key : str ,
984
+ remote_resource_region : str ,
911
985
) -> None :
912
986
attributes_dict : Dict [str , AnyValue ] = self ._get_attributes_dict (attributes_list )
913
987
self ._assert_str_attribute (attributes_dict , AWS_LOCAL_SERVICE , self .get_application_otel_service_name ())
@@ -934,8 +1008,16 @@ def _assert_aws_attributes(
934
1008
self ._assert_str_attribute (
935
1009
attributes_dict , AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER , cloudformation_primary_identifier
936
1010
)
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 )
939
1021
940
1022
@override
941
1023
def _assert_semantic_conventions_span_attributes (
@@ -1023,13 +1105,26 @@ def _assert_metric_attributes(
1023
1105
self ._assert_str_attribute (attribute_dict , AWS_SPAN_KIND , "CLIENT" )
1024
1106
remote_resource_type = kwargs .get ("remote_resource_type" , "None" )
1025
1107
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" )
1026
1111
if remote_resource_type != "None" :
1027
1112
self ._assert_str_attribute (attribute_dict , AWS_REMOTE_RESOURCE_TYPE , remote_resource_type )
1028
1113
if remote_resource_identifier != "None" :
1029
1114
if self ._is_valid_regex (remote_resource_identifier ):
1030
1115
self ._assert_match_attribute (attribute_dict , AWS_REMOTE_RESOURCE_IDENTIFIER , remote_resource_identifier )
1031
1116
else :
1032
1117
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 )
1033
1128
self .check_sum (metric_name , dependency_dp .sum , expected_sum )
1034
1129
1035
1130
attribute_dict : Dict [str , AnyValue ] = self ._get_attributes_dict (service_dp .attributes )
0 commit comments