Skip to content

Conversation

@DivMode
Copy link
Contributor

@DivMode DivMode commented Oct 24, 2025

Description

AWS Lambda accepts handler paths in both formats:

  • Slash-delimited: python/functions/api.handler
  • Dot-delimited: python.functions.api.handler

The instrumentation was failing when slash-delimited paths were used because it attempted to import invalid Python module paths containing forward slashes. This fix normalizes the handler path by converting slashes to dots before splitting the module and function names.

Fixes #1465

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added unit test test_slash_delimited_handler_path() that verifies both slash-delimited and dot-delimited handler paths work correctly
  • Tested with AWS Lambda function using slash-delimited handler (python/functions/api.handler) in production environment
  • Verified OpenTelemetry instrumentation layer successfully imports and instruments the handler
  • Previously failed with ImportError: No module named 'python/functions/api', now works correctly
  • Tested in production with SST framework which uses slash-delimited paths by default
  • All existing tests pass with the change

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated (not applicable - internal bug fix, no API changes)

AWS Lambda accepts handler paths in both formats:
- Slash-delimited: python/functions/api.handler
- Dot-delimited: python.functions.api.handler

The instrumentation was failing when slash-delimited paths were used
because it attempted to import invalid Python module paths containing
forward slashes. This fix normalizes the handler path by converting
slashes to dots before splitting the module and function names.

Fixes open-telemetry#1465
- 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 open-telemetry#1465
@DivMode DivMode requested a review from a team as a code owner October 24, 2025 00:51
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 24, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: xrmx / name: Riccardo Magliocchetti (400f554)

Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this! It lgtm, the Maintainers will also have a look.

Co-authored-by: Tammy Baylis <[email protected]>
@xrmx xrmx enabled auto-merge (squash) October 30, 2025 13:27
@xrmx xrmx merged commit b16709e into open-telemetry:main Oct 30, 2025
647 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Done in @xrmx's Python PR digest Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Slash-delimited handler paths result in ImportError within AwsLambdaInstrumentor.instrument

4 participants