-
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
feat(instrumentation): implement require-in-the-middle
singleton
#3161
Conversation
|
Awesome, this sounds promising, thank you for the PR :)) |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3161 +/- ##
==========================================
+ Coverage 93.44% 93.47% +0.02%
==========================================
Files 241 243 +2
Lines 7260 7321 +61
Branches 1507 1517 +10
==========================================
+ Hits 6784 6843 +59
- Misses 476 478 +2
|
76fcc07
to
160a2b4
Compare
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.
Love this idea. Very excited for this as its something we've been considering for a while
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Show resolved
Hide resolved
How can we progress this PR? I am really interested to speed up the start up of my projects now feels like it takes a few minutes |
I am also interested in getting this PR across the finish line. We are receiving more complaints now that we have more and more instrumentations in auto-instrumentations packages (example: #3229 (reply in thread)) |
experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts
Outdated
Show resolved
Hide resolved
a6e90ab
to
8f261d8
Compare
@mhassan1 curious what is required for you to bring this PR into a state ready for review? I have been getting increasing questions about startup cost and this would be a huge win for us. |
I've moved it out of Draft. I see some failing checks that I will address now. |
Awesome @mhassan1 looking forward trying it out :) |
3e636d9
to
285439f
Compare
I've cleaned up the PR and added more tests. This is ready for review. |
d91b05c
to
18bcfea
Compare
Unit tests are failing. I will look into it. |
With this change we are making a hard promise never to change the interface of this because of the global singleton. IMO we should upgrade this to |
I was indeed involved in that PR. It was required in order to instrument aws lambda using a layer. Thanks for the research. Sounds like a huge performance improvement. Did you happen to step through to see if it is possible to work around the issue in the aws lambda or did you just run the test? If we're intercepting all require calls, shouldn't we be able to match on an exact path the same way ritm does? |
I don't think there's anything that I also noticed that RITM passes |
Personally, I think it’s worth it to revisit lambda in the future and merge this PR as it will benefit everyone that’s not using AWS Lambda’s. I can imagine AWS/Amazon can have a closer look at it :) Yes, I am bias as I can’t use AWS in the cases I am using Opentelemetry but do have slow starts (feels to take minutes) when enabling instrumentation |
experimental/packages/opentelemetry-instrumentation/src/platform/node/ModuleNameTrie.ts
Show resolved
Hide resolved
I dismissed my review until I have time to review the updated logic. Don't want this to get merged accidentally before that based on my outdated ✅ |
@dyladan Is there anything outstanding that is blocking this PR? |
Nothing particular just trying to make sure it's sufficiently reviewed because it's quite fundamental to the instrumentation. I asked more people to review it at the SIG meeting today. |
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.
Requesting changes here so this isn't accidentally merged before @rauno56 comment is addressed
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.
Fantastic job, @mhassan1. Thanks for the work and your patience!
Which problem is this PR solving?
This PR changes the behavior of instrumentation plugins to create a single
require
patch, instead of one per plugin. This should be a significant performance improvement for projects using many instrumentation plugins.Fixes #3029.
Short description of the changes
This PR creates a
require-in-the-middle
singleton that looks for registeredonRequire
functions for a givenmodule
and executes them.Type of change
How Has This Been Tested?
This PR is mostly covered by existing tests in
InstrumentationBase.test.ts
. It adds unit tests for the logic in the_shouldHook
function.Checklist: