-
Notifications
You must be signed in to change notification settings - Fork 819
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
feat: warn when hooked module is already loaded #2926
feat: warn when hooked module is already loaded #2926
Conversation
cfd43c5
to
dc87a89
Compare
@vmarchaud As discussed, FYI |
Codecov Report
@@ Coverage Diff @@
## main #2926 +/- ##
==========================================
- Coverage 92.81% 92.19% -0.62%
==========================================
Files 184 69 -115
Lines 6066 1999 -4067
Branches 1296 437 -859
==========================================
- Hits 5630 1843 -3787
+ Misses 436 156 -280
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I remember we had it in the past and how helpful it is for debugging.
Added a few nits about the message text.
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
Yeah i actually checked because i remembered writting it, it seems that it has been lost when we moved from plugin to instrumentation |
And I remember that it used to still try and patch modules that were required before instrumentation enabled (from |
1777fc6
to
93e9302
Compare
@nozik, do you think you could add a test for it? I think the messaging coming with a |
@rauno56 What do you mean by that? |
diag logs are prefixed with the package name(or another id) they're coming from and in this case look something like this:
Even if one's unfamiliar with OTel, they can make the context out from the prefix. |
aa6dc65
to
4021e62
Compare
4021e62
to
051b5a5
Compare
Which problem is this PR solving?
A common pitfall for OTEL JS is modules that are
required
before the require-in-the-middle hook is set. In many cases, the end users don't understand why certain instrumentations aren't working, while others do.Short description of the changes
Check the require cache when initializing each instrumentation, and alert if the module was already loaded. In case it was - log a warning.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Manually
Checklist: