|
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, |
@@ -377,54 +378,68 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri |
377 | 378 | """ |
378 | 379 | remote_resource_type: Optional[str] = None |
379 | 380 | remote_resource_identifier: Optional[str] = None |
| 381 | + cloudformation_primary_identifier: Optional[str] = None |
380 | 382 |
|
381 | 383 | if is_aws_sdk_span(span): |
382 | 384 | # Only extract the table name when _AWS_TABLE_NAMES has size equals to one |
383 | 385 | if is_key_present(span, _AWS_TABLE_NAMES) and len(span.attributes.get(_AWS_TABLE_NAMES)) == 1: |
384 | 386 | remote_resource_type = _NORMALIZED_DYNAMO_DB_SERVICE_NAME + "::Table" |
385 | 387 | remote_resource_identifier = _escape_delimiters(span.attributes.get(_AWS_TABLE_NAMES)[0]) |
| 388 | + cloudformation_primary_identifier = "" |
386 | 389 | elif is_key_present(span, AWS_KINESIS_STREAM_NAME): |
387 | 390 | remote_resource_type = _NORMALIZED_KINESIS_SERVICE_NAME + "::Stream" |
388 | 391 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_KINESIS_STREAM_NAME)) |
| 392 | + cloudformation_primary_identifier = "" |
389 | 393 | elif is_key_present(span, _AWS_BUCKET_NAME): |
390 | 394 | remote_resource_type = _NORMALIZED_S3_SERVICE_NAME + "::Bucket" |
391 | 395 | remote_resource_identifier = _escape_delimiters(span.attributes.get(_AWS_BUCKET_NAME)) |
| 396 | + cloudformation_primary_identifier = "" |
392 | 397 | elif is_key_present(span, AWS_SQS_QUEUE_NAME): |
393 | 398 | remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue" |
394 | 399 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SQS_QUEUE_NAME)) |
| 400 | + cloudformation_primary_identifier = "" |
395 | 401 | elif is_key_present(span, AWS_SQS_QUEUE_URL): |
396 | 402 | remote_resource_type = _NORMALIZED_SQS_SERVICE_NAME + "::Queue" |
397 | 403 | remote_resource_identifier = _escape_delimiters( |
398 | 404 | SqsUrlParser.get_queue_name(span.attributes.get(AWS_SQS_QUEUE_URL)) |
399 | 405 | ) |
| 406 | + cloudformation_primary_identifier = "" |
400 | 407 | elif is_key_present(span, AWS_BEDROCK_AGENT_ID): |
401 | 408 | remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Agent" |
402 | 409 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_BEDROCK_AGENT_ID)) |
| 410 | + cloudformation_primary_identifier = "" |
403 | 411 | elif is_key_present(span, AWS_BEDROCK_DATA_SOURCE_ID): |
404 | 412 | remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::DataSource" |
405 | 413 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_BEDROCK_DATA_SOURCE_ID)) |
| 414 | + cloudformation_primary_identifier = "" |
406 | 415 | elif is_key_present(span, AWS_BEDROCK_GUARDRAIL_ID): |
407 | 416 | remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Guardrail" |
408 | 417 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_BEDROCK_GUARDRAIL_ID)) |
| 418 | + cloudformation_primary_identifier = "" |
409 | 419 | elif is_key_present(span, AWS_BEDROCK_KNOWLEDGE_BASE_ID): |
410 | 420 | remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::KnowledgeBase" |
411 | 421 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_BEDROCK_KNOWLEDGE_BASE_ID)) |
| 422 | + cloudformation_primary_identifier = "" |
412 | 423 | elif is_key_present(span, GEN_AI_REQUEST_MODEL): |
413 | 424 | remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Model" |
414 | 425 | remote_resource_identifier = _escape_delimiters(span.attributes.get(GEN_AI_REQUEST_MODEL)) |
| 426 | + cloudformation_primary_identifier = "" |
415 | 427 | elif is_key_present(span, AWS_SNS_TOPIC_ARN): |
416 | 428 | remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::Topic" |
417 | 429 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN)) |
| 430 | + cloudformation_primary_identifier = remote_resource_identifier |
418 | 431 | elif is_key_present(span, AWS_SECRETSMANAGER_SECRET_ARN): |
419 | 432 | remote_resource_type = _NORMALIZED_SECRETSMANAGER_SERVICE_NAME + "::Secret" |
420 | 433 | remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN)) |
| 434 | + cloudformation_primary_identifier = remote_resource_identifier |
421 | 435 | elif is_db_span(span): |
422 | 436 | remote_resource_type = _DB_CONNECTION_STRING_TYPE |
423 | 437 | remote_resource_identifier = _get_db_connection(span) |
424 | 438 |
|
425 | | - if remote_resource_type is not None and remote_resource_identifier is not None: |
| 439 | + if remote_resource_type is not None and remote_resource_identifier is not None and cloudformation_primary_identifier is not None: |
426 | 440 | attributes[AWS_REMOTE_RESOURCE_TYPE] = remote_resource_type |
427 | 441 | attributes[AWS_REMOTE_RESOURCE_IDENTIFIER] = remote_resource_identifier |
| 442 | + attributes[AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER] = cloudformation_primary_identifier |
428 | 443 |
|
429 | 444 |
|
430 | 445 | def _get_db_connection(span: ReadableSpan) -> None: |
|
0 commit comments