-
Notifications
You must be signed in to change notification settings - Fork 743
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
Error loading plugin when it is already being patched by require-in-the-middle #1461
Comments
It looks like the issue is that |
Thanks @dyladan for looking into it. I tried out your suggestion locally and it seems to resolve the issue. Would you accept a PR for it or will you be looking into it? |
For me, when following https://github.com/open-telemetry/opentelemetry-js/blob/master/getting-started/ts-example/README.md#getting-started-with-opentelemetry-js-typescript but then moving to set the specific plugins I want to load, specifying |
@maxmil7 sorry this took so long but I opened a PR |
No problem. Thanks @dyladan! |
What version of OpenTelemetry are you using?
What version of Node are you using?
v12.17.0
What did you do?
I was trying to integrate open telemetry modules for NodeJS with my app, and saw the following error when starting the app:
The issue is reproducible if you run the following piece of code:
What did you expect to see?
plugin-http
andplugin-https
libraries should have registered without any errorWhat did you see instead?
There was an error registering the
plugin-http
libraryAdditional context
In the sample code above,
https
core module is required beforehttp
module.This results in the following events:
https
module is required,require-in-the-middle
loadsplugin-https
to patch it.plugin-https
imports@opentelemetry/plugin-http
moduleplugin-http
imports corehttp
libraryrequire-in-the-middle
loads thehttp
library and executes the patch hookplugin-http
modulerequire-in-the-middle
, it returns the current exports object, which doesn't have all the exported functionsAdd any other context about the problem here.
There are other ways to reproduce this as well for eg:
After registering the provider, just
require('@opentelemetry/plugin-http')
will result in the same issue. Or any other plugin for that matter which imports the same core library.I tried to think of a solve but couldn't come up with a clean solution. If anyone can point me in the right direction, I am happy to submit a PR for the issue
The text was updated successfully, but these errors were encountered: