-
Notifications
You must be signed in to change notification settings - Fork 821
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
Can not use ESM support in lambda environment #4842
Labels
bug
Something isn't working
priority:p2
Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
triage
Comments
@nikhileshcr-splunk The links in the Additional Details section look to be linked to a private repo; can you double check and replace with links to code we can access to help out? Thanks! |
JamieDanielson
added
the
priority:p2
Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
label
Jul 10, 2024
Hi @JamieDanielson, my bad. Thanks for the reply and looking into the issue. |
jj22ee
pushed a commit
to aws-observability/aws-otel-js-instrumentation
that referenced
this issue
Oct 11, 2024
*Description of changes:* 1. Add `IS_ESM` check in `otel_instrument` wrapper before calling lambda handler. If it is EMS format, add ESM node-options [supported](https://github.com/open-telemetry/opentelemetry-js/blob/966ac176af249d86de6cb10feac2306062846768/doc/esm-support.md#esm-options-for-different-versions-of-nodejs) by OTel community. Added a new wrapper script `otel_instrument_esm` if the esm auto detection logic is failed, customer can opt-in to tell tell layer go with ESM instrumentation path. 2. Set a new env var `HANDLER_IS_ESM` for lambda function when ESM is detected 3. Patch aws-lambda instrumentation, when `IS_ESM` env var is set, apply ESM supported `InstrumentationNodeModuleDefinition` to patch function handler, otherwise keep using the existing handler patcher. Note: this change add a new branch for supporting ESM, the existing CommonJS path should not be impacted. 1. open-telemetry/opentelemetry-js#4842 2. open-telemetry/opentelemetry-js-contrib#1942 *Test* ``` 2024-10-09T20:38:13.411-07:00 | Instrumenting lambda handler { -- | -- | 2024-10-09T20:38:13.411-07:00 | taskRoot: '/var/task', | 2024-10-09T20:38:13.411-07:00 | handlerDef: 'index.handler', | 2024-10-09T20:38:13.411-07:00 | handler: 'index.handler', | 2024-10-09T20:38:13.411-07:00 | moduleRoot: '', | 2024-10-09T20:38:13.411-07:00 | module: 'index', | 2024-10-09T20:38:13.411-07:00 | filename: '/var/task/index.mjs', | 2024-10-09T20:38:13.411-07:00 | functionName: 'handler' | 2024-10-09T20:38:13.411-07:00 | } | 2024-10-09T20:38:15.386-07:00 | 'cloud.account.id': '252610625673', -- | -- | -- | 2024-10-09T20:38:15.386-07:00 | 'aws.is.local.root': true, | 2024-10-09T20:38:15.386-07:00 | 'aws.local.service': 'TestESM', | 2024-10-09T20:38:15.386-07:00 | 'aws.local.operation': 'TestESM/Handler', | 2024-10-09T20:38:15.386-07:00 | 'aws.span.kind': 'LOCAL_ROOT' ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
priority:p2
Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect
triage
What happened?
I am trying to instrument ESM lambdas using the ESM support feature added in #3698 and the feature is not working in the lambda environment.
Steps to Reproduce
@opentelemetry/instrumentation/hook.mjs
in the lambda wrapper.Expected Result
The lambda should be instrumented and should send traces to the collector.
Actual Result
We are not seeing any traces being sent to the collector.
Additional Details
I reckon there's an issue with
import-in-the-middle
which internally usesmodule-details-from-path
's parse method to get thebaseDir
value. It requires modules to be in a node_modules directory to work.We are getting
undefiend
for thebaseDire
value in thehookfn
here.And since the
baseDir
isundefined
, the_onRequire
method unexpectedly returns from here.OpenTelemetry Setup Code
Splunk's Otel wrapper, https://github.com/signalfx/splunk-otel-lambda/blob/main/nodejs/src/wrapper.ts
package.json
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: