Skip to content

Commit a1ab00e

Browse files
committed
add lambda assertions in span client test
1 parent 133d544 commit a1ab00e

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,62 @@ def test_sdk_client_span_with_remote_resource_attributes(self):
12861286
[AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_FUNCTION_ARN, SpanAttributes.RPC_METHOD], [None, None, None]
12871287
)
12881288

1289+
# Validate behaviour of AWS_LAMBDA_NAME for non-Invoke operations (treated as resource)
1290+
self._mock_attribute(
1291+
[
1292+
SpanAttributes.RPC_SYSTEM,
1293+
SpanAttributes.RPC_SERVICE,
1294+
SpanAttributes.RPC_METHOD,
1295+
AWS_LAMBDA_FUNCTION_NAME,
1296+
AWS_LAMBDA_FUNCTION_ARN,
1297+
],
1298+
[
1299+
"aws-api",
1300+
"Lambda",
1301+
"GetFunction",
1302+
"testLambdaName",
1303+
"arn:aws:lambda:us-east-1:123456789012:function:testLambdaName",
1304+
],
1305+
keys,
1306+
values,
1307+
)
1308+
self._validate_remote_resource_attributes(
1309+
"AWS::Lambda::Function", "testLambdaName", "arn:aws:lambda:us-east-1:123456789012:function:testLambdaName"
1310+
)
1311+
self._mock_attribute(
1312+
[
1313+
SpanAttributes.RPC_SYSTEM,
1314+
SpanAttributes.RPC_SERVICE,
1315+
SpanAttributes.RPC_METHOD,
1316+
AWS_LAMBDA_FUNCTION_NAME,
1317+
AWS_LAMBDA_FUNCTION_ARN,
1318+
],
1319+
[None, None, None, None, None],
1320+
)
1321+
1322+
# Validate that Lambda Invoke with function name treats Lambda as a service, not a resource
1323+
self._mock_attribute(
1324+
[
1325+
SpanAttributes.RPC_SYSTEM,
1326+
SpanAttributes.RPC_SERVICE,
1327+
SpanAttributes.RPC_METHOD,
1328+
AWS_LAMBDA_FUNCTION_NAME,
1329+
],
1330+
["aws-api", "Lambda", "Invoke", "testLambdaName"],
1331+
keys,
1332+
values,
1333+
)
1334+
self._validate_remote_resource_attributes(None, None)
1335+
self._mock_attribute(
1336+
[
1337+
SpanAttributes.RPC_SYSTEM,
1338+
SpanAttributes.RPC_SERVICE,
1339+
SpanAttributes.RPC_METHOD,
1340+
AWS_LAMBDA_FUNCTION_NAME,
1341+
],
1342+
[None, None, None, None],
1343+
)
1344+
12891345
self._mock_attribute([SpanAttributes.RPC_SYSTEM], [None])
12901346

12911347
def test_client_db_span_with_remote_resource_attributes(self):

0 commit comments

Comments
 (0)