1010 AWS_BEDROCK_DATA_SOURCE_ID ,
1111 AWS_BEDROCK_GUARDRAIL_ID ,
1212 AWS_BEDROCK_KNOWLEDGE_BASE_ID ,
13+ AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER ,
1314 AWS_KINESIS_STREAM_NAME ,
1415 AWS_LOCAL_OPERATION ,
1516 AWS_LOCAL_SERVICE ,
@@ -372,6 +373,7 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
372373 """
373374 remote_resource_type : Optional [str ] = None
374375 remote_resource_identifier : Optional [str ] = None
376+ cloudformation_primary_identifier : Optional [str ] = None
375377
376378 if is_aws_sdk_span (span ):
377379 # Only extract the table name when _AWS_TABLE_NAMES has size equals to one
@@ -387,17 +389,24 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
387389 elif is_key_present (span , AWS_SQS_QUEUE_NAME ):
388390 remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
389391 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_SQS_QUEUE_NAME ))
392+ cloudformation_primary_identifier = _escape_delimiters (span .attributes .get (AWS_SQS_QUEUE_URL ))
390393 elif is_key_present (span , AWS_SQS_QUEUE_URL ):
391394 remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
392395 remote_resource_identifier = _escape_delimiters (
393396 SqsUrlParser .get_queue_name (span .attributes .get (AWS_SQS_QUEUE_URL ))
394397 )
398+ cloudformation_primary_identifier = _escape_delimiters (span .attributes .get (AWS_SQS_QUEUE_URL ))
395399 elif is_key_present (span , AWS_BEDROCK_AGENT_ID ):
396400 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Agent"
397401 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_AGENT_ID ))
398402 elif is_key_present (span , AWS_BEDROCK_DATA_SOURCE_ID ):
399403 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::DataSource"
400404 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_DATA_SOURCE_ID ))
405+ cloudformation_primary_identifier = (
406+ _escape_delimiters (span .attributes .get (AWS_BEDROCK_KNOWLEDGE_BASE_ID ))
407+ + "|"
408+ + remote_resource_identifier
409+ )
401410 elif is_key_present (span , AWS_BEDROCK_GUARDRAIL_ID ):
402411 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Guardrail"
403412 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_GUARDRAIL_ID ))
@@ -411,9 +420,19 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
411420 remote_resource_type = _DB_CONNECTION_STRING_TYPE
412421 remote_resource_identifier = _get_db_connection (span )
413422
414- if remote_resource_type is not None and remote_resource_identifier is not None :
423+ # If the CFN Primary Id is still None here, that means it is not an edge case.
424+ # Then, we can just assign it the same value as remote_resource_identifier
425+ if cloudformation_primary_identifier is None :
426+ cloudformation_primary_identifier = remote_resource_identifier
427+
428+ if (
429+ remote_resource_type is not None
430+ and remote_resource_identifier is not None
431+ and cloudformation_primary_identifier is not None
432+ ):
415433 attributes [AWS_REMOTE_RESOURCE_TYPE ] = remote_resource_type
416434 attributes [AWS_REMOTE_RESOURCE_IDENTIFIER ] = remote_resource_identifier
435+ attributes [AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER ] = cloudformation_primary_identifier
417436
418437
419438def _get_db_connection (span : ReadableSpan ) -> None :
0 commit comments