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
crash when using aws-lambda instrumentation #2193
Comments
I believe this is happening because lambda have a require path behavior than node itself, i'm converting this into an issue since its a bug in the base instrumentation class |
Thanks for bringing this up, here's the problematic require in the base instrumentation: opentelemetry-js/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts Line 76 in 1758fa6
One suggestion is we could use pkginfo which is made for this use case. All it does is recursively search up the file tree for the first |
I would prefer to have this logic in the base instrumentation to avoid the dependency indeed (specially since we only need this code for the node platform) |
I don't believe that amazon has a different require behavior. They do change some of the require path configuration, but I believe the resolution behavior is still the documented node behavior. |
When is this bug triggered? I assume not for all lambda invocations, so does it only happen when the user application doesn't have a package.json? Which module is being intercepted that uses the user's application as the base path? Is it the load of the user application itself? |
Based on @adambartholomew's original issue, it sounds like there was a package.json at the root of the function bundle (at One thing I'm unclear on is what exactly |
|
Ok that makes sense. I think the root issue here is that the Lambda instrumentation follows a different pattern for declaring its target module instrumentation. Typically, instrumented modules are well-defined module names (e.g. The problem now is that
|
I'm pretty sure (3) is already the case. |
I think it's required? opentelemetry-js/packages/opentelemetry-instrumentation/src/platform/node/types.ts Line 45 in 1758fa6
|
Ah I think probably we made it required so authors would have to manually put |
Could we not lookup the version if we see |
That's what I was thinking. If the |
Is there consensus on the solution? The most recent suggestion was to only read the package.json if supportedVersions does not contain |
I took a stab at this back in May, and ended up stashing it as it didn't match the exact solution proposed above. I was honestly just hoping someone more experienced would pick it up. It was extremely challenging to do a simple I do not have enough understanding on the importance of these versions throughout this package, modules, and exports to be comfortable enough to change the behaviour of these methods. This is the closest I got without any major refactoring: This has been tested exclusively with unit tests, and should help raise the overall coverage on these classes. I have not loaded this into any real-world aws-lambda instrumentation projects for testing. |
@vmarchaud The PR was merged (#2450) - should we close the ticket? |
Is this released, because im getting this error with all latest versions |
I think we are waiting for a new release of @opentelemetry/instrumentation-aws-lambda. The confusing thing is the latest version of @opentelemetry/instrumentation-aws-lambda is 0.26.0 which is the version of @opentelemetry/instrumentation which contains the fix. |
I've been running into an exception where the JS auto-instrumentation attempts to load
package.json
from the base path of a lambda handler. Is there a way to customize the path from/var/task/src/handlers/my-function-name/package.json
to a higher level/var/task/package.json
or/opt/my-extension/package.json
?Copying the package.json into the expected locations causes the instrumentation to work as expected, it would just be painful for the project's build process.
Setup:
Exception:
Originally posted by @adambartholomew in #2192
The text was updated successfully, but these errors were encountered: