Skip to content

Commit fe89da9

Browse files
committed
Add changelog and unit test for slash-delimited handler fix
- Add changelog entry in Unreleased section - Add unit test verifying both slash and dot-delimited handler paths work - Test confirms instrumentation handles both formats correctly Related to #1465
1 parent 50f8e9e commit fe89da9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Fixed
15+
16+
- `opentelemetry-instrumentation-aws-lambda`: Fix ImportError with slash-delimited handler paths
17+
([#1465](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1465))
18+
1419
## Version 1.38.0/0.59b0 (2025-10-16)
1520

1621
### Fixed

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,53 @@ def test_sqs_event_sets_attributes(self):
727727
MOCK_LAMBDA_CONTEXT_ATTRIBUTES,
728728
)
729729

730+
def test_slash_delimited_handler_path(self):
731+
"""Test that slash-delimited handler paths work correctly.
732+
733+
AWS Lambda accepts both slash-delimited (python/functions/api.handler)
734+
and dot-delimited (python.functions.api.handler) handler paths.
735+
This test ensures the instrumentation handles both formats.
736+
"""
737+
# Test slash-delimited format
738+
slash_env_patch = mock.patch.dict(
739+
"os.environ",
740+
{_HANDLER: "tests/mocks/lambda_function.handler"},
741+
)
742+
slash_env_patch.start()
743+
AwsLambdaInstrumentor().instrument()
744+
745+
mock_execute_lambda()
746+
747+
spans = self.memory_exporter.get_finished_spans()
748+
self.assertEqual(len(spans), 1)
749+
self.assertSpanHasAttributes(
750+
spans[0],
751+
MOCK_LAMBDA_CONTEXT_ATTRIBUTES,
752+
)
753+
754+
slash_env_patch.stop()
755+
AwsLambdaInstrumentor().uninstrument()
756+
self.memory_exporter.clear()
757+
758+
# Test dot-delimited format (should still work)
759+
dot_env_patch = mock.patch.dict(
760+
"os.environ",
761+
{_HANDLER: "tests.mocks.lambda_function.handler"},
762+
)
763+
dot_env_patch.start()
764+
AwsLambdaInstrumentor().instrument()
765+
766+
mock_execute_lambda()
767+
768+
spans = self.memory_exporter.get_finished_spans()
769+
self.assertEqual(len(spans), 1)
770+
self.assertSpanHasAttributes(
771+
spans[0],
772+
MOCK_LAMBDA_CONTEXT_ATTRIBUTES,
773+
)
774+
775+
dot_env_patch.stop()
776+
730777
def test_lambda_handles_handler_exception_with_api_gateway_proxy_event(
731778
self,
732779
):

0 commit comments

Comments
 (0)