Skip to content

Commit f05d295

Browse files
committed
fix: Correct remote_resource_identifier attribute values for SNS, SecretsManager, and SFN
1 parent 6765867 commit f05d295

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/_aws_metric_attribute_generator.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,20 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
436436
remote_resource_identifier = _escape_delimiters(span.attributes.get(GEN_AI_REQUEST_MODEL))
437437
elif is_key_present(span, AWS_SECRETSMANAGER_SECRET_ARN):
438438
remote_resource_type = _NORMALIZED_SECRETSMANAGER_SERVICE_NAME + "::Secret"
439-
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN))
439+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN)).split(":")[-1]
440+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN))
440441
elif is_key_present(span, AWS_SNS_TOPIC_ARN):
441442
remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::Topic"
442-
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN))
443+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN)).split(":")[-1]
444+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN))
443445
elif is_key_present(span, AWS_STEPFUNCTIONS_STATEMACHINE_ARN):
444446
remote_resource_type = _NORMALIZED_STEPFUNCTIONS_SERVICE_NAME + "::StateMachine"
445-
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_STATEMACHINE_ARN))
447+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_STATEMACHINE_ARN)).split(":")[-1]
448+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_STATEMACHINE_ARN))
446449
elif is_key_present(span, AWS_STEPFUNCTIONS_ACTIVITY_ARN):
447450
remote_resource_type = _NORMALIZED_STEPFUNCTIONS_SERVICE_NAME + "::Activity"
448-
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_ACTIVITY_ARN))
451+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_ACTIVITY_ARN)).split(":")[-1]
452+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_ACTIVITY_ARN))
449453
elif is_key_present(span, AWS_LAMBDA_RESOURCEMAPPING_ID):
450454
remote_resource_type = _NORMALIZED_LAMBDA_SERVICE_NAME + "::EventSourceMapping"
451455
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_LAMBDA_RESOURCEMAPPING_ID))

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/test_aws_metric_attribute_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,13 +1111,13 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
11111111
values,
11121112
)
11131113
self._validate_remote_resource_attributes(
1114-
"AWS::SecretsManager::Secret", "arn:aws:secretsmanager:us-east-1:123456789012:secret:secret_name-lERW9H"
1114+
"AWS::SecretsManager::Secret", "secret_name-lERW9H"
11151115
)
11161116
self._mock_attribute([AWS_SECRETSMANAGER_SECRET_ARN], [None])
11171117

11181118
# Validate behaviour of AWS_SNS_TOPIC_ARN attribute, then remove it.
11191119
self._mock_attribute([AWS_SNS_TOPIC_ARN], ["arn:aws:sns:us-west-2:012345678901:test_topic"], keys, values)
1120-
self._validate_remote_resource_attributes("AWS::SNS::Topic", "arn:aws:sns:us-west-2:012345678901:test_topic")
1120+
self._validate_remote_resource_attributes("AWS::SNS::Topic", "test_topic")
11211121
self._mock_attribute([AWS_SNS_TOPIC_ARN], [None])
11221122

11231123
# Validate behaviour of AWS_STEPFUNCTIONS_STATEMACHINE_ARN attribute, then remove it.
@@ -1128,7 +1128,7 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
11281128
values,
11291129
)
11301130
self._validate_remote_resource_attributes(
1131-
"AWS::StepFunctions::StateMachine", "arn:aws:states:us-east-1:123456789012:stateMachine:test_state_machine"
1131+
"AWS::StepFunctions::StateMachine", "test_state_machine"
11321132
)
11331133
self._mock_attribute([AWS_STEPFUNCTIONS_STATEMACHINE_ARN], [None])
11341134

@@ -1140,7 +1140,7 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
11401140
values,
11411141
)
11421142
self._validate_remote_resource_attributes(
1143-
"AWS::StepFunctions::Activity", "arn:aws:states:us-east-1:007003123456789012:activity:testActivity"
1143+
"AWS::StepFunctions::Activity", "testActivity"
11441144
)
11451145
self._mock_attribute([AWS_STEPFUNCTIONS_ACTIVITY_ARN], [None])
11461146

0 commit comments

Comments
 (0)