Skip to content

Commit 24404f2

Browse files
committed
add CFN primary identifier, fix contract tests
1 parent aa6748e commit 24404f2

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
@@ -428,11 +428,13 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
428428
{
429429
remoteResourceType = NormalizedSecretsManagerServiceName + "::Secret";
430430
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn)).Split(":").Last();
431+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSecretsManagerSecretArn));
431432
}
432433
else if (IsKeyPresent(span, AttributeAWSSNSTopicArn))
433434
{
434435
remoteResourceType = NormalizedSNSServiceName + "::Topic";
435436
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn)).Split(":").Last();
437+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSSNSTopicArn));
436438
}
437439
else if (IsKeyPresent(span, AttributeAWSSQSQueueName))
438440
{
@@ -450,11 +452,13 @@ private static void SetRemoteResourceTypeAndIdentifier(Activity span, ActivityTa
450452
{
451453
remoteResourceType = NormalizedStepFunctionsName + "::Activity";
452454
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsActivityArn)).Split(":").Last();
455+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsActivityArn));
453456
}
454457
else if (IsKeyPresent(span, AttributeAWSStepFunctionsStateMachineArn))
455458
{
456459
remoteResourceType = NormalizedStepFunctionsName + "::StateMachine";
457460
remoteResourceIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsStateMachineArn)).Split(":").Last();
461+
cloudformationPrimaryIdentifier = EscapeDelimiters((string?)span.GetTagItem(AttributeAWSStepFunctionsStateMachineArn));
458462
}
459463
else if (IsKeyPresent(span, AttributeAWSBedrockGuardrailId))
460464
{

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
},
@@ -515,6 +525,7 @@ def test_stepfunctions_error(self):
515525
# remote_operation="ListStateMachineVersions",
516526
# remote_resource_type="AWS::StepFunctions::StateMachine",
517527
# remote_resource_identifier="invalid-state-machine",
528+
# cloudformation_primary_identifier="arn:aws:states:us-east-1:000000000000:stateMachine:invalid-state-machine",
518529
# request_response_specific_attributes={
519530
# _AWS_STEPFUNCTIONS_STATE_MACHINE_ARN: "arn:aws:states:us-east-1:000000000000:stateMachine:invalid-state-machine",},
520531
# span_name="SFN.ListStateMachineVersions",

0 commit comments

Comments
 (0)