Skip to content

Commit 831b76b

Browse files
authored
feat: Support a list of new AWS resources for AWS Python SDK (#265)
### *Description of changes:* These changes add auto-instrumentation support for the following AWS resources. Additionally, a new attribute for `aws.remote.resource.cfn.primary.identifier` is also added for each new resource. - Populate `aws.sns.topic.arn` in Span by extracting `TopicArn` from the request body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-topic.html - The CFN Id should be the ARN of the Topic. - Populate `aws.secretsmanager.secret.arn` in Span by extracting `ARN` from response body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-secretsmanager-secret.html - The CFN Id should be the ARN of the Secret. - Populate `aws.stepfunctions.state_machine.arn` in Span by extracting `stateMachineArn` from the request body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-statemachine.html - The CFN Id should be the ARN of the State Machine. - Populate `aws.stepfunctions.activity.arn` in Span by extracting `activityArn` from the request body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html - The CFN Id should be the ARN of the Activity. - Populate `aws.lambda.function.name` in Span by extracting `FunctionName` from the request body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html - The CFN Id should be the ARN of the Lambda Function. - We populate `aws.lambda.function.arn` in Span by extraction `FunctionArn` from the response body because users are allowed to pass in both the name and ARN in the request body to retrieve the Lambda Function. - Populate `aws.lambda.resource_mapping.id` in Span by extracting `UUID` from the request body. - https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html - The CFN Id should be the UUID of the Event Source Mapping. ### *Test Plan:* Set up a client-server with auto-instrumentation to verify that the correct span data is being generated. ![sns_topic_arn_span_data_verification](https://github.com/user-attachments/assets/f744ef66-169e-4056-9151-eb17d74258c8) ![secretsmanager_secret_arn_span_data_verification](https://github.com/user-attachments/assets/ee3cd0d6-3ecd-4f55-8471-b69eea4a369a) ![sfn_statemachine_arn_span_data_verification](https://github.com/user-attachments/assets/cd857153-c61c-4368-9d9f-eb91a90dc0f3) ![sfn_activity_arn_span_data_verification](https://github.com/user-attachments/assets/6e5d20d3-00c4-4dc2-a692-91e26e1f13f3) ![lambda_function_name_span_data_verification](https://github.com/user-attachments/assets/d019c94a-b944-4fa3-be62-b80ab3209899) ![lambda_event_source_mapping_uuid_span_data_verification](https://github.com/user-attachments/assets/968f0488-9440-457a-828e-1a1e4e6f2c5f) Unit Tests for Instrumentation Patches and AWS Metric Attribute Generators. ![instrumentation_patch_unit_test_verification](https://github.com/user-attachments/assets/5322a47e-dc7e-4b67-9c6f-158cffde6787) ![aws_metric_attribute_generator_unit_test_verification](https://github.com/user-attachments/assets/8672e0d6-eb05-424c-9005-281c239053c0) By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 825fe58 commit 831b76b

File tree

5 files changed

+330
-2
lines changed

5 files changed

+330
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@
2323
AWS_BEDROCK_KNOWLEDGE_BASE_ID: str = "aws.bedrock.knowledge_base.id"
2424
AWS_BEDROCK_AGENT_ID: str = "aws.bedrock.agent.id"
2525
AWS_BEDROCK_GUARDRAIL_ID: str = "aws.bedrock.guardrail.id"
26+
AWS_SECRETSMANAGER_SECRET_ARN: str = "aws.secretsmanager.secret.arn"
27+
AWS_SNS_TOPIC_ARN: str = "aws.sns.topic.arn"
28+
AWS_STEPFUNCTIONS_STATEMACHINE_ARN: str = "aws.stepfunctions.state_machine.arn"
29+
AWS_STEPFUNCTIONS_ACTIVITY_ARN: str = "aws.stepfunctions.activity.arn"
30+
AWS_LAMBDA_FUNCTION_NAME: str = "aws.lambda.function.name"
31+
AWS_LAMBDA_RESOURCEMAPPING_ID: str = "aws.lambda.resource_mapping.id"
32+
AWS_LAMBDA_FUNCTION_ARN: str = "aws.lambda.function.arn"

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@
1212
AWS_BEDROCK_KNOWLEDGE_BASE_ID,
1313
AWS_CLOUDFORMATION_PRIMARY_IDENTIFIER,
1414
AWS_KINESIS_STREAM_NAME,
15+
AWS_LAMBDA_FUNCTION_ARN,
16+
AWS_LAMBDA_FUNCTION_NAME,
17+
AWS_LAMBDA_RESOURCEMAPPING_ID,
1518
AWS_LOCAL_OPERATION,
1619
AWS_LOCAL_SERVICE,
1720
AWS_REMOTE_DB_USER,
1821
AWS_REMOTE_OPERATION,
1922
AWS_REMOTE_RESOURCE_IDENTIFIER,
2023
AWS_REMOTE_RESOURCE_TYPE,
2124
AWS_REMOTE_SERVICE,
25+
AWS_SECRETSMANAGER_SECRET_ARN,
26+
AWS_SNS_TOPIC_ARN,
2227
AWS_SPAN_KIND,
2328
AWS_SQS_QUEUE_NAME,
2429
AWS_SQS_QUEUE_URL,
30+
AWS_STEPFUNCTIONS_ACTIVITY_ARN,
31+
AWS_STEPFUNCTIONS_STATEMACHINE_ARN,
2532
)
2633
from amazon.opentelemetry.distro._aws_span_processing_util import (
2734
GEN_AI_REQUEST_MODEL,
@@ -88,6 +95,10 @@
8895
_NORMALIZED_SQS_SERVICE_NAME: str = "AWS::SQS"
8996
_NORMALIZED_BEDROCK_SERVICE_NAME: str = "AWS::Bedrock"
9097
_NORMALIZED_BEDROCK_RUNTIME_SERVICE_NAME: str = "AWS::BedrockRuntime"
98+
_NORMALIZED_SECRETSMANAGER_SERVICE_NAME: str = "AWS::SecretsManager"
99+
_NORMALIZED_SNS_SERVICE_NAME: str = "AWS::SNS"
100+
_NORMALIZED_STEPFUNCTIONS_SERVICE_NAME: str = "AWS::StepFunctions"
101+
_NORMALIZED_LAMBDA_SERVICE_NAME: str = "AWS::Lambda"
91102
_DB_CONNECTION_STRING_TYPE: str = "DB::Connection"
92103

93104
# Special DEPENDENCY attribute value if GRAPHQL_OPERATION_TYPE attribute key is present.
@@ -309,6 +320,9 @@ def _normalize_remote_service_name(span: ReadableSpan, service_name: str) -> str
309320
"Bedrock Agent": _NORMALIZED_BEDROCK_SERVICE_NAME,
310321
"Bedrock Agent Runtime": _NORMALIZED_BEDROCK_SERVICE_NAME,
311322
"Bedrock Runtime": _NORMALIZED_BEDROCK_RUNTIME_SERVICE_NAME,
323+
"Secrets Manager": _NORMALIZED_SECRETSMANAGER_SERVICE_NAME,
324+
"SNS": _NORMALIZED_SNS_SERVICE_NAME,
325+
"SFN": _NORMALIZED_STEPFUNCTIONS_SERVICE_NAME,
312326
}
313327
return aws_sdk_service_mapping.get(service_name, "AWS::" + service_name)
314328
return service_name
@@ -359,7 +373,7 @@ def _generate_remote_operation(span: ReadableSpan) -> str:
359373
return remote_operation
360374

361375

362-
# pylint: disable=too-many-branches
376+
# pylint: disable=too-many-branches,too-many-statements
363377
def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttributes) -> None:
364378
"""
365379
Remote resource attributes {@link AwsAttributeKeys#AWS_REMOTE_RESOURCE_TYPE} and {@link
@@ -416,6 +430,37 @@ def _set_remote_type_and_identifier(span: ReadableSpan, attributes: BoundedAttri
416430
elif is_key_present(span, GEN_AI_REQUEST_MODEL):
417431
remote_resource_type = _NORMALIZED_BEDROCK_SERVICE_NAME + "::Model"
418432
remote_resource_identifier = _escape_delimiters(span.attributes.get(GEN_AI_REQUEST_MODEL))
433+
elif is_key_present(span, AWS_SECRETSMANAGER_SECRET_ARN):
434+
remote_resource_type = _NORMALIZED_SECRETSMANAGER_SERVICE_NAME + "::Secret"
435+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN)).split(
436+
":"
437+
)[-1]
438+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_SECRETSMANAGER_SECRET_ARN))
439+
elif is_key_present(span, AWS_SNS_TOPIC_ARN):
440+
remote_resource_type = _NORMALIZED_SNS_SERVICE_NAME + "::Topic"
441+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN)).split(":")[-1]
442+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_SNS_TOPIC_ARN))
443+
elif is_key_present(span, AWS_STEPFUNCTIONS_STATEMACHINE_ARN):
444+
remote_resource_type = _NORMALIZED_STEPFUNCTIONS_SERVICE_NAME + "::StateMachine"
445+
remote_resource_identifier = _escape_delimiters(
446+
span.attributes.get(AWS_STEPFUNCTIONS_STATEMACHINE_ARN)
447+
).split(":")[-1]
448+
cloudformation_primary_identifier = _escape_delimiters(
449+
span.attributes.get(AWS_STEPFUNCTIONS_STATEMACHINE_ARN)
450+
)
451+
elif is_key_present(span, AWS_STEPFUNCTIONS_ACTIVITY_ARN):
452+
remote_resource_type = _NORMALIZED_STEPFUNCTIONS_SERVICE_NAME + "::Activity"
453+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_ACTIVITY_ARN)).split(
454+
":"
455+
)[-1]
456+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_STEPFUNCTIONS_ACTIVITY_ARN))
457+
elif is_key_present(span, AWS_LAMBDA_RESOURCEMAPPING_ID):
458+
remote_resource_type = _NORMALIZED_LAMBDA_SERVICE_NAME + "::EventSourceMapping"
459+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_LAMBDA_RESOURCEMAPPING_ID))
460+
elif is_key_present(span, AWS_LAMBDA_FUNCTION_NAME):
461+
remote_resource_type = _NORMALIZED_LAMBDA_SERVICE_NAME + "::Function"
462+
remote_resource_identifier = _escape_delimiters(span.attributes.get(AWS_LAMBDA_FUNCTION_NAME))
463+
cloudformation_primary_identifier = _escape_delimiters(span.attributes.get(AWS_LAMBDA_FUNCTION_ARN))
419464
elif is_db_span(span):
420465
remote_resource_type = _DB_CONNECTION_STRING_TYPE
421466
remote_resource_identifier = _get_db_connection(span)

aws-opentelemetry-distro/src/amazon/opentelemetry/distro/patches/_botocore_patches.py

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55

66
from amazon.opentelemetry.distro._aws_attribute_keys import (
77
AWS_KINESIS_STREAM_NAME,
8+
AWS_LAMBDA_FUNCTION_ARN,
9+
AWS_LAMBDA_FUNCTION_NAME,
10+
AWS_LAMBDA_RESOURCEMAPPING_ID,
11+
AWS_SECRETSMANAGER_SECRET_ARN,
12+
AWS_SNS_TOPIC_ARN,
813
AWS_SQS_QUEUE_NAME,
914
AWS_SQS_QUEUE_URL,
15+
AWS_STEPFUNCTIONS_ACTIVITY_ARN,
16+
AWS_STEPFUNCTIONS_STATEMACHINE_ARN,
1017
)
1118
from amazon.opentelemetry.distro.patches._bedrock_patches import ( # noqa # pylint: disable=unused-import
1219
_BedrockAgentExtension,
@@ -15,9 +22,12 @@
1522
_BedrockRuntimeExtension,
1623
)
1724
from opentelemetry.instrumentation.botocore.extensions import _KNOWN_EXTENSIONS
25+
from opentelemetry.instrumentation.botocore.extensions.lmbd import _LambdaExtension
26+
from opentelemetry.instrumentation.botocore.extensions.sns import _SnsExtension
1827
from opentelemetry.instrumentation.botocore.extensions.sqs import _SqsExtension
19-
from opentelemetry.instrumentation.botocore.extensions.types import _AttributeMapT, _AwsSdkExtension
28+
from opentelemetry.instrumentation.botocore.extensions.types import _AttributeMapT, _AwsSdkExtension, _BotoResultT
2029
from opentelemetry.semconv.trace import SpanAttributes
30+
from opentelemetry.trace.span import Span
2131

2232

2333
def _apply_botocore_instrumentation_patches() -> None:
@@ -29,6 +39,100 @@ def _apply_botocore_instrumentation_patches() -> None:
2939
_apply_botocore_s3_patch()
3040
_apply_botocore_sqs_patch()
3141
_apply_botocore_bedrock_patch()
42+
_apply_botocore_secretsmanager_patch()
43+
_apply_botocore_sns_patch()
44+
_apply_botocore_stepfunctions_patch()
45+
_apply_botocore_lambda_patch()
46+
47+
48+
def _apply_botocore_lambda_patch() -> None:
49+
"""Botocore instrumentation patch for Lambda
50+
51+
This patch adds an extension to the upstream's list of known extensions for Lambda.
52+
Extensions allow for custom logic for adding service-specific information to spans,
53+
such as attributes. Specifically, we are adding logic to add the
54+
`aws.lambda.function.name` and `aws.lambda.resource_mapping.id` attributes
55+
56+
Sidenote: There exists SpanAttributes.FAAS_INVOKED_NAME for invoke operations
57+
in upstream. However, we want to cover more operations to extract 'FunctionName',
58+
so we define `aws.lambda.function.name` separately. Additionally, this helps
59+
us maintain naming consistency with the other AWS resources.
60+
"""
61+
old_extract_attributes = _LambdaExtension.extract_attributes
62+
63+
def patch_extract_attributes(self, attributes: _AttributeMapT):
64+
old_extract_attributes(self, attributes)
65+
# This param can be passed as an arn or a name. We standardize it to be the name.
66+
function_name_param = self._call_context.params.get("FunctionName")
67+
if function_name_param:
68+
function_name = function_name_param
69+
if function_name_param.startswith("arn:aws:lambda:"):
70+
function_name = function_name_param.split(":")[-1]
71+
attributes[AWS_LAMBDA_FUNCTION_NAME] = function_name
72+
resource_mapping_id = self._call_context.params.get("UUID")
73+
if resource_mapping_id:
74+
attributes[AWS_LAMBDA_RESOURCEMAPPING_ID] = resource_mapping_id
75+
76+
old_on_success = _LambdaExtension.on_success
77+
78+
def patch_on_success(self, span: Span, result: _BotoResultT):
79+
old_on_success(self, span, result)
80+
lambda_configuration = result.get("Configuration", {})
81+
function_arn = lambda_configuration.get("FunctionArn")
82+
if function_arn:
83+
span.set_attribute(AWS_LAMBDA_FUNCTION_ARN, function_arn)
84+
85+
_LambdaExtension.extract_attributes = patch_extract_attributes
86+
_LambdaExtension.on_success = patch_on_success
87+
88+
89+
def _apply_botocore_stepfunctions_patch() -> None:
90+
"""Botocore instrumentation patch for StepFunctions
91+
92+
This patch adds an extension to the upstream's list of known extensions for
93+
StepFunctions. Extensions allow for custom logic for adding service-specific
94+
information to spans, such as attributes. Specifically, we are adding logic
95+
to add the `aws.stepfunctions.state_machine.arn` and `aws.stepfunctions.activity.arn`
96+
attributes, to be used to generate RemoteTarget and achieve partity with the
97+
Java instrumentation.
98+
"""
99+
_KNOWN_EXTENSIONS["stepfunctions"] = _lazy_load(".", "_StepFunctionsExtension")
100+
101+
102+
def _apply_botocore_sns_patch() -> None:
103+
"""Botocore instrumentation patch for SNS
104+
105+
This patch adds an extension to the upstream's list of known extensions for SNS.
106+
Extensions allow for custom logic for adding service-specific information to
107+
spans, such as attributes. Specifically, we are adding logic to add the
108+
`aws.sns.topic.arn` attribute, to be used to generate RemoteTarget and achieve
109+
parity with the Java instrumentation.
110+
111+
Sidenote: There exists SpanAttributes.MESSAGING_DESTINATION_NAME in the upstream
112+
logic that we could re-purpose here. We do not use it here to maintain consistent
113+
naming patterns with other AWS resources.
114+
"""
115+
old_extract_attributes = _SnsExtension.extract_attributes
116+
117+
def patch_extract_attributes(self, attributes: _AttributeMapT):
118+
old_extract_attributes(self, attributes)
119+
topic_arn = self._call_context.params.get("TopicArn")
120+
if topic_arn:
121+
attributes[AWS_SNS_TOPIC_ARN] = topic_arn
122+
123+
_SnsExtension.extract_attributes = patch_extract_attributes
124+
125+
126+
def _apply_botocore_secretsmanager_patch() -> None:
127+
"""Botocore instrumentation patch for SecretsManager
128+
129+
This patch adds an extension to the upstream's list of known extension for SecretsManager.
130+
Extensions allow for custom logic for adding service-specific information to spans, such as
131+
attributes. Specifically, we are adding logic to add the `aws.secretsmanager.secret.arn`
132+
attribute, to be used to generate RemoteTarget and achieve parity with the Java
133+
instrumentation.
134+
"""
135+
_KNOWN_EXTENSIONS["secretsmanager"] = _lazy_load(".", "_SecretsManagerExtension")
32136

33137

34138
def _apply_botocore_kinesis_patch() -> None:
@@ -108,6 +212,34 @@ def loader():
108212
# END The OpenTelemetry Authors code
109213

110214

215+
class _StepFunctionsExtension(_AwsSdkExtension):
216+
def extract_attributes(self, attributes: _AttributeMapT):
217+
state_machine_arn = self._call_context.params.get("stateMachineArn")
218+
if state_machine_arn:
219+
attributes[AWS_STEPFUNCTIONS_STATEMACHINE_ARN] = state_machine_arn
220+
activity_arn = self._call_context.params.get("activityArn")
221+
if activity_arn:
222+
attributes[AWS_STEPFUNCTIONS_ACTIVITY_ARN] = activity_arn
223+
224+
225+
class _SecretsManagerExtension(_AwsSdkExtension):
226+
def extract_attributes(self, attributes: _AttributeMapT):
227+
"""
228+
SecretId can be secret name or secret arn, the function extracts attributes
229+
only if the SecretId parameter is provided as an arn which starts with
230+
`arn:aws:secretsmanager:`
231+
"""
232+
secret_id = self._call_context.params.get("SecretId")
233+
if secret_id and secret_id.startswith("arn:aws:secretsmanager:"):
234+
attributes[AWS_SECRETSMANAGER_SECRET_ARN] = secret_id
235+
236+
# pylint: disable=no-self-use
237+
def on_success(self, span: Span, result: _BotoResultT):
238+
secret_arn = result.get("ARN")
239+
if secret_arn:
240+
span.set_attribute(AWS_SECRETSMANAGER_SECRET_ARN, secret_arn)
241+
242+
111243
class _S3Extension(_AwsSdkExtension):
112244
def extract_attributes(self, attributes: _AttributeMapT):
113245
bucket_name = self._call_context.params.get("Bucket")

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@
1414
AWS_BEDROCK_KNOWLEDGE_BASE_ID,
1515
AWS_CONSUMER_PARENT_SPAN_KIND,
1616
AWS_KINESIS_STREAM_NAME,
17+
AWS_LAMBDA_FUNCTION_NAME,
18+
AWS_LAMBDA_RESOURCEMAPPING_ID,
1719
AWS_LOCAL_OPERATION,
1820
AWS_LOCAL_SERVICE,
1921
AWS_REMOTE_DB_USER,
2022
AWS_REMOTE_OPERATION,
2123
AWS_REMOTE_RESOURCE_IDENTIFIER,
2224
AWS_REMOTE_RESOURCE_TYPE,
2325
AWS_REMOTE_SERVICE,
26+
AWS_SECRETSMANAGER_SECRET_ARN,
27+
AWS_SNS_TOPIC_ARN,
2428
AWS_SPAN_KIND,
2529
AWS_SQS_QUEUE_NAME,
2630
AWS_SQS_QUEUE_URL,
31+
AWS_STEPFUNCTIONS_ACTIVITY_ARN,
32+
AWS_STEPFUNCTIONS_STATEMACHINE_ARN,
2733
)
2834
from amazon.opentelemetry.distro._aws_metric_attribute_generator import _AwsMetricAttributeGenerator
2935
from amazon.opentelemetry.distro._aws_span_processing_util import GEN_AI_REQUEST_MODEL
@@ -877,6 +883,9 @@ def test_normalize_remote_service_name_aws_sdk(self):
877883
self.validate_aws_sdk_service_normalization("Bedrock Agent", "AWS::Bedrock")
878884
self.validate_aws_sdk_service_normalization("Bedrock Agent Runtime", "AWS::Bedrock")
879885
self.validate_aws_sdk_service_normalization("Bedrock Runtime", "AWS::BedrockRuntime")
886+
self.validate_aws_sdk_service_normalization("Secrets Manager", "AWS::SecretsManager")
887+
self.validate_aws_sdk_service_normalization("SNS", "AWS::SNS")
888+
self.validate_aws_sdk_service_normalization("SFN", "AWS::StepFunctions")
880889

881890
def validate_aws_sdk_service_normalization(self, service_name: str, expected_remote_service: str):
882891
self._mock_attribute([SpanAttributes.RPC_SYSTEM, SpanAttributes.RPC_SERVICE], ["aws-api", service_name])
@@ -1093,6 +1102,62 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
10931102
self._validate_remote_resource_attributes("AWS::Bedrock::Model", "test.service_^^id")
10941103
self._mock_attribute([GEN_AI_REQUEST_MODEL], [None])
10951104

1105+
# Validate behaviour of AWS_SECRETSMANAGER_SECRET_ARN attribute, then remove it.
1106+
self._mock_attribute(
1107+
[AWS_SECRETSMANAGER_SECRET_ARN],
1108+
["arn:aws:secretsmanager:us-east-1:123456789012:secret:secret_name-lERW9H"],
1109+
keys,
1110+
values,
1111+
)
1112+
self._validate_remote_resource_attributes("AWS::SecretsManager::Secret", "secret_name-lERW9H")
1113+
self._mock_attribute([AWS_SECRETSMANAGER_SECRET_ARN], [None])
1114+
1115+
# Validate behaviour of AWS_SNS_TOPIC_ARN attribute, then remove it.
1116+
self._mock_attribute([AWS_SNS_TOPIC_ARN], ["arn:aws:sns:us-west-2:012345678901:test_topic"], keys, values)
1117+
self._validate_remote_resource_attributes("AWS::SNS::Topic", "test_topic")
1118+
self._mock_attribute([AWS_SNS_TOPIC_ARN], [None])
1119+
1120+
# Validate behaviour of AWS_STEPFUNCTIONS_STATEMACHINE_ARN attribute, then remove it.
1121+
self._mock_attribute(
1122+
[AWS_STEPFUNCTIONS_STATEMACHINE_ARN],
1123+
["arn:aws:states:us-east-1:123456789012:stateMachine:test_state_machine"],
1124+
keys,
1125+
values,
1126+
)
1127+
self._validate_remote_resource_attributes("AWS::StepFunctions::StateMachine", "test_state_machine")
1128+
self._mock_attribute([AWS_STEPFUNCTIONS_STATEMACHINE_ARN], [None])
1129+
1130+
# Validate behaviour of AWS_STEPFUNCTIONS_ACTIVITY_ARN attribute, then remove it.
1131+
self._mock_attribute(
1132+
[AWS_STEPFUNCTIONS_ACTIVITY_ARN],
1133+
["arn:aws:states:us-east-1:007003123456789012:activity:testActivity"],
1134+
keys,
1135+
values,
1136+
)
1137+
self._validate_remote_resource_attributes("AWS::StepFunctions::Activity", "testActivity")
1138+
self._mock_attribute([AWS_STEPFUNCTIONS_ACTIVITY_ARN], [None])
1139+
1140+
# Validate behaviour of AWS_LAMBDA_FUNCTION_NAME attribute, then remove it.
1141+
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME], ["aws_lambda_function_name"], keys, values)
1142+
self._validate_remote_resource_attributes("AWS::Lambda::Function", "aws_lambda_function_name")
1143+
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME], [None])
1144+
1145+
# Validate behaviour of AWS_LAMBDA_RESOURCEMAPPING_ID attribute, then remove it.
1146+
self._mock_attribute([AWS_LAMBDA_RESOURCEMAPPING_ID], ["aws_event_source_mapping_id"], keys, values)
1147+
self._validate_remote_resource_attributes("AWS::Lambda::EventSourceMapping", "aws_event_source_mapping_id")
1148+
self._mock_attribute([AWS_LAMBDA_RESOURCEMAPPING_ID], [None])
1149+
1150+
# Validate behaviour of both AWS_LAMBDA_FUNCTION_NAME and AWS_LAMBDA_RESOURCE_MAPPING_ID,
1151+
# then remove it.
1152+
self._mock_attribute(
1153+
[AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_RESOURCEMAPPING_ID],
1154+
["aws_lambda_function_name", "aws_event_source_mapping_id"],
1155+
keys,
1156+
values,
1157+
)
1158+
self._validate_remote_resource_attributes("AWS::Lambda::EventSourceMapping", "aws_event_source_mapping_id")
1159+
self._mock_attribute([AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_RESOURCEMAPPING_ID], [None, None])
1160+
10961161
self._mock_attribute([SpanAttributes.RPC_SYSTEM], [None])
10971162

10981163
def test_client_db_span_with_remote_resource_attributes(self):

0 commit comments

Comments
 (0)