-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(instrumentation-aws-lambda): support ESM handlers and other less common handler patterns #2000
base: main
Are you sure you want to change the base?
feat(instrumentation-aws-lambda): support ESM handlers and other less common handler patterns #2000
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2000 +/- ##
==========================================
- Coverage 90.79% 90.66% -0.14%
==========================================
Files 169 165 -4
Lines 8009 7757 -252
Branches 1632 1610 -22
==========================================
- Hits 7272 7033 -239
+ Misses 737 724 -13
|
This comment was marked as outdated.
This comment was marked as outdated.
4190e62
to
4676273
Compare
@JamieDanielson I think you've been pushing a lot for ESM support as a whole, if I rebased this do you think you'd be able to take a look ? |
6452504
to
d68a079
Compare
@jj22ee a review would be much appreciated when you have some time |
Hi, I see that there have been merged changes recently to support ESM handlers while not changing the implementation in It looks like that ESM handlers will be supported once all these changes are released in the latest OTel JS version. |
The changes wouldn't be needed for ESM support no, and this PR could be updated to take advantage of proper support for absolute path. I'd personally argue for still merging given it supports strictly more valid handler patterns and properly tests support for ESM (which the merged PR did not) and these other patterns. @trentm sorry to ping you for the 10th time the past couple days, but as the reviewer of the ESM support PR do you have any thoughts wrt what to do with this one ? |
Which problem is this PR solving?
The Lambda instrumentation doesn't currently support instrumenting ESM handlers, which are now the default, and other less common handler patterns supported by Lambda such as extensionless handler modules and nested handler functions.
Short description of the changes
The previous logic to determine the handler to patch is replaced with an implementation based on the one present in the Lambda runtime. I tried to keep the function names and structure as close to possible to the original to make it easier to cross-reference.
The tests also now use code copied from the Lambda runtime to load handlers, as opposed to just calling
require
which doesn't properly reflect a real-world scenario and doesn't work at all for ESM.I also updated the notes about absolute path support in the patching infrastructure. The instrumentation keeps using the same hack but it would probably be a good idea to fix the issue upstream, which is that while absolute paths are taken into account while registering hooks, they are not when matching against the module name within the hook function, which ignores the
baseDir
.