Skip to content

Commit 6223db0

Browse files
committed
add CFN primary identifier, fix contract tests
1 parent 33be376 commit 6223db0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/AWS.Distro.OpenTelemetry.AutoInstrumentation/AwsMetricAttributeGenerator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,13 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
424424
{
425425
remoteResourceType = NormalizedSecretsManagerServiceName + "::Secret";
426426
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn)).Split(":").Last();
427+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn));
427428
}
428429
else if (IsKeyPresent(span, AttributeAWSSNSTopicArn))
429430
{
430431
remoteResourceType = NormalizedSNSServiceName + "::Topic";
431432
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn)).Split(":").Last();
433+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn));
432434
}
433435
else if (IsKeyPresent(span, AttributeAWSSQSQueueName))
434436
{
@@ -446,11 +448,13 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
446448
{
447449
remoteResourceType = NormalizedStepFunctionsName + "::Activity";
448450
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsActivityArn)).Split(":").Last();
451+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsActivityArn));
449452
}
450453
else if (IsKeyPresent(span, AttributeAWSStepFunctionsStateMachineArn))
451454
{
452455
remoteResourceType = NormalizedStepFunctionsName + "::StateMachine";
453456
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsStateMachineArn)).Split(":").Last();
457+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsStateMachineArn));
454458
}
455459
else if (IsKeyPresent(span, AttributeAWSBedrockGuardrailId))
456460
{

test/contract-tests/tests/test/amazon/awssdk/awssdk_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ def test_secretsmanager_create_secret(self):
336336
remote_operation="CreateSecret",
337337
remote_resource_type="AWS::SecretsManager::Secret",
338338
remote_resource_identifier=r"test-secret-[a-zA-Z0-9]{6}$",
339+
cloudformation_primary_identifier=r"arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-[a-zA-Z0-9]{6}$",
339340
request_response_specific_attributes={
340341
_AWS_SECRETSMANAGER_SECRET_ARN: r"arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-[a-zA-Z0-9]{6}$",
341342
},
@@ -354,6 +355,7 @@ def test_secretsmanager_get_secret_value(self):
354355
remote_operation="GetSecretValue",
355356
remote_resource_type="AWS::SecretsManager::Secret",
356357
remote_resource_identifier=r"test-secret-[a-zA-Z0-9]{6}$",
358+
cloudformation_primary_identifier=r"arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-[a-zA-Z0-9]{6}$",
357359
request_response_specific_attributes={
358360
_AWS_SECRETSMANAGER_SECRET_ARN: r"arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-[a-zA-Z0-9]{6}$",
359361
},
@@ -372,6 +374,7 @@ def test_secretsmanager_error(self):
372374
remote_operation="DescribeSecret",
373375
remote_resource_type="AWS::SecretsManager::Secret",
374376
remote_resource_identifier="test-secret-error",
377+
cloudformation_primary_identifier="arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-error",
375378
request_response_specific_attributes={
376379
_AWS_SECRETSMANAGER_SECRET_ARN: "arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-error",
377380
},
@@ -391,6 +394,7 @@ def test_secretsmanager_error(self):
391394
# remote_operation="CreateSecret",
392395
# remote_resource_type="AWS::SecretsManager::Secret",
393396
# remote_resource_identifier="test-secret-error",
397+
# cloudformation_primary_identifier="arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-error",
394398
# request_response_specific_attributes={
395399
# _AWS_SECRETSMANAGER_SECRET_ARN: "arn:aws:secretsmanager:us-east-1:000000000000:secret:test-secret-error",
396400
# },
@@ -408,6 +412,7 @@ def test_sns_publish(self):
408412
remote_operation="Publish",
409413
remote_resource_type="AWS::SNS::Topic",
410414
remote_resource_identifier="test-topic",
415+
cloudformation_primary_identifier="arn:aws:sns:us-east-1:000000000000:test-topic",
411416
request_response_specific_attributes={
412417
_AWS_SNS_TOPIC_ARN: "arn:aws:sns:us-east-1:000000000000:test-topic",
413418
},
@@ -425,6 +430,7 @@ def test_sns_error(self):
425430
remote_operation="Publish",
426431
remote_resource_type="AWS::SNS::Topic",
427432
remote_resource_identifier="test-topic-error",
433+
cloudformation_primary_identifier="arn:aws:sns:us-east-1:000000000000:test-topic-error",
428434
request_response_specific_attributes={
429435
_AWS_SNS_TOPIC_ARN: "arn:aws:sns:us-east-1:000000000000:test-topic-error",
430436
},
@@ -443,6 +449,7 @@ def test_sns_error(self):
443449
# remote_operation="GetTopicAttributes",
444450
# remote_resource_type="AWS::SNS::Topic",
445451
# remote_resource_identifier="invalid-topic",
452+
# cloudformation_primary_identifier="arn:aws:sns:us-east-1:000000000000:invalid-topic",
446453
# request_response_specific_attributes={
447454
# _AWS_SNS_TOPIC_ARN: "arn:aws:sns:us-east-1:000000000000:invalid-topic",},
448455
# span_name="SNS.GetTopicAttributes"
@@ -460,6 +467,7 @@ def test_stepfunctions_describe_state_machine(self):
460467
remote_operation="DescribeStateMachine",
461468
remote_resource_type="AWS::StepFunctions::StateMachine",
462469
remote_resource_identifier="test-state-machine",
470+
cloudformation_primary_identifier="arn:aws:states:us-east-1:000000000000:stateMachine:test-state-machine",
463471
request_response_specific_attributes={
464472
_AWS_STEPFUNCTIONS_STATE_MACHINE_ARN: "arn:aws:states:us-east-1:000000000000:stateMachine:test-state-machine",
465473
},
@@ -478,6 +486,7 @@ def test_stepfunctions_describe_activity(self):
478486
remote_operation="DescribeActivity",
479487
remote_resource_type="AWS::StepFunctions::Activity",
480488
remote_resource_identifier="test-activity",
489+
cloudformation_primary_identifier="arn:aws:states:us-east-1:000000000000:activity:test-activity",
481490
request_response_specific_attributes={
482491
_AWS_STEPFUNCTIONS_ACTIVITY_ARN: "arn:aws:states:us-east-1:000000000000:activity:test-activity",
483492
},
@@ -496,6 +505,7 @@ def test_stepfunctions_error(self):
496505
remote_operation="DescribeStateMachine",
497506
remote_resource_type="AWS::StepFunctions::StateMachine",
498507
remote_resource_identifier="error-state-machine",
508+
cloudformation_primary_identifier="arn:aws:states:us-east-1:000000000000:stateMachine:error-state-machine",
499509
request_response_specific_attributes={
500510
_AWS_STEPFUNCTIONS_STATE_MACHINE_ARN: "arn:aws:states:us-east-1:000000000000:stateMachine:error-state-machine",
501511
},
@@ -516,6 +526,7 @@ def test_stepfunctions_error(self):
516526
# remote_operation="ListStateMachineVersions",
517527
# remote_resource_type="AWS::StepFunctions::StateMachine",
518528
# remote_resource_identifier="invalid-state-machine",
529+
# cloudformation_primary_identifier="arn:aws:states:us-east-1:000000000000:stateMachine:invalid-state-machine",
519530
# request_response_specific_attributes={
520531
# _AWS_STEPFUNCTIONS_STATE_MACHINE_ARN: "arn:aws:states:us-east-1:000000000000:stateMachine:invalid-state-machine",},
521532
# span_name="SFN.ListStateMachineVersions",

0 commit comments

Comments
 (0)