10
10
AWS_BEDROCK_DATA_SOURCE_ID ,
11
11
AWS_BEDROCK_GUARDRAIL_ID ,
12
12
AWS_BEDROCK_KNOWLEDGE_BASE_ID ,
13
+ AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER ,
13
14
AWS_KINESIS_STREAM_NAME ,
14
15
AWS_LOCAL_OPERATION ,
15
16
AWS_LOCAL_SERVICE ,
@@ -372,6 +373,7 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
372
373
"""
373
374
remote_resource_type : Optional [str ] = None
374
375
remote_resource_identifier : Optional [str ] = None
376
+ cloudformation_primary_identifier : Optional [str ] = None
375
377
376
378
if is_aws_sdk_span (span ):
377
379
# 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
387
389
elif is_key_present (span , AWS_SQS_QUEUE_NAME ):
388
390
remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
389
391
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 ))
390
393
elif is_key_present (span , AWS_SQS_QUEUE_URL ):
391
394
remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue"
392
395
remote_resource_identifier = _escape_delimiters (
393
396
SqsUrlParser .get_queue_name (span .attributes .get (AWS_SQS_QUEUE_URL ))
394
397
)
398
+ cloudformation_primary_identifier = _escape_delimiters (span .attributes .get (AWS_SQS_QUEUE_URL ))
395
399
elif is_key_present (span , AWS_BEDROCK_AGENT_ID ):
396
400
remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Agent"
397
401
remote_resource_identifier = _escape_delimiters (span .attributes .get (AWS_BEDROCK_AGENT_ID ))
398
402
elif is_key_present (span , AWS_BEDROCK_DATA_SOURCE_ID ):
399
403
remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::DataSource"
400
404
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
+ )
401
410
elif is_key_present (span , AWS_BEDROCK_GUARDRAIL_ID ):
402
411
remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Guardrail"
403
412
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
411
420
remote_resource_type = _DB_CONNECTION_STRING_TYPE
412
421
remote_resource_identifier = _get_db_connection (span )
413
422
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
+ ):
415
433
attributes [AWS_REMOTE_RESOURCE_TYPE ] = remote_resource_type
416
434
attributes [AWS_REMOTE_RESOURCE_IDENTIFIER ] = remote_resource_identifier
435
+ attributes [AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER ] = cloudformation_primary_identifier
417
436
418
437
419
438
def _get_db_connection (span : ReadableSpan ) -> None :
0 commit comments