Skip to content
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

Support instrumentation of express when using ESModules #4490

Closed
1 task done
tobiasmuehl opened this issue Feb 17, 2024 · 2 comments
Closed
1 task done

Support instrumentation of express when using ESModules #4490

tobiasmuehl opened this issue Feb 17, 2024 · 2 comments

Comments

@tobiasmuehl
Copy link

tobiasmuehl commented Feb 17, 2024

  • This only affects the JavaScript OpenTelemetry library

As explained in the docs there is experimental support for projects that use ES Modules as well as a sample app with a http server. This all works great until Node 18.

Using express instead of http doesn't work though. I found a WIP to make express work (stale PR) but it doesn't seem to be completed:

It moans about the module loading order, even though in the sample app @opentelemetry/instrumentation-express is clearly loaded before express.

❯ yarn start-express
yarn run v1.22.21
$ node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./build/express.js
(node:48798) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
@opentelemetry/api: Registered a global for diag v1.7.0.
@opentelemetry/api: Registered a global for trace v1.7.0.
@opentelemetry/api: Registered a global for context v1.7.0.
@opentelemetry/api: Registered a global for propagation v1.7.0.
@opentelemetry/instrumentation-express Module express has been loaded before @opentelemetry/instrumentation-express so it might not work, please initialize it before requiring express
Applying patch for express@4.18.2
hello!
No modules instrumentation has been defined for 'test-autoinstrumentions@0.0.1', nothing will be patched
Now listening on: http://0.0.0.0:3000/

Are there plans in place to support express using esm?

Likely related:

@tobiasmuehl
Copy link
Author

@tobiasmuehl tobiasmuehl closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
@tobiasmuehl
Copy link
Author

tobiasmuehl commented Feb 18, 2024

🎉 I found a working solution here! My project is using esm and I switched my runtime from node to jiti and NOW EVERYTHING JUST WORKS!!!!!! even works on node20

If we are living in a simulation then this is a complete cheat code 🥷🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant