Skip to content

Cannot find module '@opentelemetry/api #1715

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

Closed
deepcrawltech opened this issue Feb 21, 2025 · 4 comments
Closed

Cannot find module '@opentelemetry/api #1715

deepcrawltech opened this issue Feb 21, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@deepcrawltech
Copy link

Describe the bug
Get this error in lambda when bundling with esbuild.

Steps to reproduce
Create a lambda function using CDK NodeJSFunction factory. Add layers and configure bundling with:
externalModules: [
"@opentelemetry/api",
"@opentelemetry/sdk-node",
"@opentelemetry/auto-instrumentations-node",
"@opentelemetry/exporter-metrics-otlp-http",
"@opentelemetry/sdk-metrics",
],

What did you expect to see?
Lambda starts

What did you see instead?
I see @opentelemetry/api error

What version of collector/language SDK version did you use?
opentelemetry-nodejs-0_12_0

What language layer did you use?
nodejs

Additional context
This used to work with opentelemetry-nodejs-0_11_0

@deepcrawltech deepcrawltech added the bug Something isn't working label Feb 21, 2025
@serkan-ozal
Copy link
Contributor

Hi @deepcrawltech,

What error logs do you see about @opentelemetry/api?

And I guess, it is caused by the bundling of OTEL JS layer itself. Since OTEL JS layer is bundled in the latest release (to reduce coldstart delay significantly: #1679), you can't use OTEL packages from layer itself as they are bundled and not visible by import/require in your code.

So, what I suggest you is that for the OTEL packages you directly reference in your own code (for ex. @opentelemetry/api in your case), keep them in your bundle (not define them as external).

In summary, can you try by removing "@opentelemetry/api" from externalModules from your CDK bundle config?

@deepcrawltech
Copy link
Author

Yeah I can try that

@serkan-ozal
Copy link
Contributor

Hi @deepcrawltech,

Had you a chance to try my suggestion? If so, did it work?

@deepcrawltech
Copy link
Author

Yes it works that way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants