@@ -378,52 +378,56 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
378378 """
379379 remote_resource_type : Optional [str ] = None
380380 remote_resource_identifier : Optional [str ] = None
381+ # In most cases, this will be the same as remote_resource_identifier.
382+ # However, there are a few edge cases we have to handle such as compound CFN identifiers.
381383 cloudformation_primary_identifier : Optional [str ] = None
382384
383385 if is_aws_sdk_span (span ):
384386 # Only extract the table name when _AWS_TABLE_NAMES has size equals to one
385387 if is_key_present (span , _AWS_TABLE_NAMES ) and len (span .attributes .get (_AWS_TABLE_NAMES )) == 1 :
386388 remote_resource_type = _NORMALIZED_DYNAMO_DB_SERVICE_NAME + "::Table"
387389 remote_resource_identifier = _escape_delimiters (span .attributes .get (_AWS_TABLE_NAMES )[0 ])
388- cloudformation_primary_identifier = ""
390+ cloudformation_primary_identifier = remote_resource_identifier
389391 elif is_key_present (span , AWS_KINESIS_STREAM_NAME ):
390392 remote_resource_type = _NORMALIZED_KINESIS_SERVICE_NAME + "::Stream"
391393 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_KINESIS_STREAM_NAME ))
392- cloudformation_primary_identifier = ""
394+ cloudformation_primary_identifier = remote_resource_identifier
393395 elif is_key_present (span , _AWS_BUCKET_NAME ):
394396 remote_resource_type = _NORMALIZED_S3_SERVICE_NAME + "::Bucket"
395397 remote_resource_identifier = _escape_delimiters (span .attributes .get (_AWS_BUCKET_NAME ))
396- cloudformation_primary_identifier = ""
398+ cloudformation_primary_identifier = remote_resource_identifier
397399 elif is_key_present (span , AWS_SQS_QUEUE_NAME ):
398400 remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
399401 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_SQS_QUEUE_NAME ))
400- cloudformation_primary_identifier = ""
402+ cloudformation_primary_identifier = _escape_delimiters ( span . attributes . get ( AWS_SQS_QUEUE_URL ))
401403 elif is_key_present (span , AWS_SQS_QUEUE_URL ):
402404 remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
403405 remote_resource_identifier = _escape_delimiters (
404406 SqsUrlParser .get_queue_name (span .attributes .get (AWS_SQS_QUEUE_URL ))
405407 )
406- cloudformation_primary_identifier = ""
408+ cloudformation_primary_identifier = _escape_delimiters ( span . attributes . get ( AWS_SQS_QUEUE_URL ))
407409 elif is_key_present (span , AWS_BEDROCK_AGENT_ID ):
408410 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Agent"
409411 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_AGENT_ID ))
410- cloudformation_primary_identifier = ""
412+ cloudformation_primary_identifier = remote_resource_identifier
411413 elif is_key_present (span , AWS_BEDROCK_DATA_SOURCE_ID ):
412414 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::DataSource"
413415 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_DATA_SOURCE_ID ))
414- cloudformation_primary_identifier = ""
416+ cloudformation_primary_identifier = _escape_delimiters ( span . attributes . get ( AWS_BEDROCK_KNOWLEDGE_BASE_ID )) + "|" + remote_resource_identifier
415417 elif is_key_present (span , AWS_BEDROCK_GUARDRAIL_ID ):
416418 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Guardrail"
417419 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_GUARDRAIL_ID ))
418- cloudformation_primary_identifier = ""
420+ cloudformation_primary_identifier = remote_resource_identifier
419421 elif is_key_present (span , AWS_BEDROCK_KNOWLEDGE_BASE_ID ):
420422 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::KnowledgeBase"
421423 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_KNOWLEDGE_BASE_ID ))
422- cloudformation_primary_identifier = ""
424+ cloudformation_primary_identifier = remote_resource_identifier
423425 elif is_key_present (span , GEN_AI_REQUEST_MODEL ):
424426 remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Model"
425427 remote_resource_identifier = _escape_delimiters (span .attributes .get (GEN_AI_REQUEST_MODEL ))
426- cloudformation_primary_identifier = ""
428+ # TODO: AWS::Bedrock::Model is not currently listed in CloudControl API
429+ # Going with this assumption for now. May need to change later.
430+ cloudformation_primary_identifier = remote_resource_identifier
427431 elif is_key_present (span , AWS_SNS_TOPIC_ARN ):
428432 remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::Topic"
429433 remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_SNS_TOPIC_ARN ))
0 commit comments