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
fix(instr-express): keep hidden properties in layer handlers #2137
base: main
Are you sure you want to change the base?
fix(instr-express): keep hidden properties in layer handlers #2137
Conversation
@@ -165,8 +165,7 @@ export class ExpressInstrumentation extends InstrumentationBase< | |||
) { | |||
const route = original.apply(this, args); | |||
const layer = this._router.stack[this._router.stack.length - 1]; | |||
instrumentation._applyPatch.call( | |||
instrumentation, | |||
instrumentation._applyPatch( |
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.
Note for reviewer: this usage of Function.protptype.call
comes from this commit 0723d06 as a new addition.
I did not dig further to get the original implementation but I think there is no need to use .call(...)
since we have access to the container object and therefore calling _applyPatch
with the right context.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2137 +/- ##
==========================================
- Coverage 90.97% 90.45% -0.52%
==========================================
Files 146 149 +3
Lines 7492 7599 +107
Branches 1502 1591 +89
==========================================
+ Hits 6816 6874 +58
- Misses 676 725 +49
|
This is due to no tests are manipulating the hidden properties of the I can remove the setter since until now not having the property at all was not breaking apps. But I think is a matter of time to get a new issue because of a lib trying to update those rops |
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.
Thanks @david-luna ! I will review this week. In the meantime can you run npm run lint:fix
to update the lint errors?
Which problem is this PR solving?
handle
function of an express layer may contain certain metadata, specially in therouter
layer. When instrumentation does the "patch" the patched function does not have the same properties so any code relying on those props will find nothing. That may not be the case inexpress
itself but 3rd party tools that look into that metadata are failing.Fixes: #1950
Short description of the changes
handle
function.stack
property is available for the router layer.