From f89e4ce215fee342490385dff623bf007513a879 Mon Sep 17 00:00:00 2001 From: wpessers Date: Sun, 15 Mar 2026 23:23:56 +0100 Subject: [PATCH 1/2] feat(python): add function_name field to Lambda Context mock class --- python/src/otel/otel_sdk/nodeps-requirements.txt | 2 +- python/src/otel/tests/nodeps-requirements.txt | 2 +- python/src/otel/tests/test_otel.py | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/python/src/otel/otel_sdk/nodeps-requirements.txt b/python/src/otel/otel_sdk/nodeps-requirements.txt index 742f35317b..ccc1430563 100644 --- a/python/src/otel/otel_sdk/nodeps-requirements.txt +++ b/python/src/otel/otel_sdk/nodeps-requirements.txt @@ -1,4 +1,4 @@ # TODO: move these dependencies to requirements.txt when they stopped relying on a pinned version of # opentelemetry-propagator-aws-xray -opentelemetry-instrumentation-aws-lambda==0.60b1 +opentelemetry-instrumentation-aws-lambda==0.61b0 opentelemetry-instrumentation-botocore==0.60b1 diff --git a/python/src/otel/tests/nodeps-requirements.txt b/python/src/otel/tests/nodeps-requirements.txt index 3ce1c84589..e782276676 100644 --- a/python/src/otel/tests/nodeps-requirements.txt +++ b/python/src/otel/tests/nodeps-requirements.txt @@ -1 +1 @@ -opentelemetry-instrumentation-aws-lambda==0.60b1 +opentelemetry-instrumentation-aws-lambda==0.61b0 diff --git a/python/src/otel/tests/test_otel.py b/python/src/otel/tests/test_otel.py index c59c99015a..2f9877e14d 100644 --- a/python/src/otel/tests/test_otel.py +++ b/python/src/otel/tests/test_otel.py @@ -53,14 +53,16 @@ class MockLambdaContext: - def __init__(self, aws_request_id, invoked_function_arn): + def __init__(self, aws_request_id, invoked_function_arn, function_name): self.invoked_function_arn = invoked_function_arn self.aws_request_id = aws_request_id + self.function_name = function_name MOCK_LAMBDA_CONTEXT = MockLambdaContext( aws_request_id="mock_aws_request_id", invoked_function_arn="arn:aws:lambda:us-west-2:123456789012:function:my-function", + function_name="my-function", ) MOCK_XRAY_TRACE_ID = 0x5FB7331105E8BB83207FA31D4D9CDB4C From aea83f5639be7d2464718c73307771c58a59ae85 Mon Sep 17 00:00:00 2001 From: wpessers Date: Sun, 15 Mar 2026 23:26:04 +0100 Subject: [PATCH 2/2] feat(python): assert span name matches lambda function name and align test data --- python/src/otel/tests/test_otel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/src/otel/tests/test_otel.py b/python/src/otel/tests/test_otel.py index 2f9877e14d..057e8c1b4a 100644 --- a/python/src/otel/tests/test_otel.py +++ b/python/src/otel/tests/test_otel.py @@ -190,7 +190,7 @@ def setUp(self): "os.environ", { AWS_LAMBDA_EXEC_WRAPPER: "mock_aws_lambda_exec_wrapper", - AWS_LAMBDA_FUNCTION_NAME: "test-func", + AWS_LAMBDA_FUNCTION_NAME: "my-function", _HANDLER: "mocks.lambda_function.handler", }, ) @@ -239,7 +239,7 @@ def test_active_tracing(self): self.assertEqual(len(spans), 1) span = spans[0] - self.assertEqual(span.name, os.environ[ORIG_HANDLER]) + self.assertEqual(span.name, MOCK_LAMBDA_CONTEXT.function_name) self.assertEqual(span.get_span_context().trace_id, MOCK_XRAY_TRACE_ID) self.assertEqual(span.kind, SpanKind.SERVER) self.assertSpanHasAttributes(