-
Notifications
You must be signed in to change notification settings - Fork 823
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(http-instrumentation): add content size attributes to spans #1771
feat(http-instrumentation): add content size attributes to spans #1771
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1771 +/- ##
==========================================
+ Coverage 92.15% 92.18% +0.03%
==========================================
Files 165 165
Lines 5568 5594 +26
Branches 1197 1204 +7
==========================================
+ Hits 5131 5157 +26
Misses 437 437
|
bb283aa
to
2fff599
Compare
* @param { IncomingMessage } Request object whose headers will be analyzed | ||
* @param { Attributes } Attributes object to be modified | ||
*/ | ||
export const setRequestContentLengthAttribute = ( |
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.
What is the benefit of these functions?
It seems they are only called from tests but not from the plugin code itself.
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.
They are called just under by getOutgoingRequestAttributesOnResponse
and getIncomingRequestAttributes
function getContentLength( | ||
headers: OutgoingHttpHeaders | IncomingHttpHeaders | ||
): number | null { | ||
const contentLengthHeader = headers['content-length']; |
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.
At least for outgoing HTTP users may specify headers with any casing.
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.
They should be lower-cased by node when set: https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js#L572
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.
You refer to the object used by node http internally on symbol kOutHeaders
accessible via the apis setHeader
/ getHeader
/... on outgoing requests.
But actually this is not applicable here. outgoing messages have not .header property at all.
But it seems this is no problem because this plugin captures content-size only for server requests (incoming) and client response (also incoming) where node parses and prepares the lowercased headers.
Co-authored-by: Gerhard Stöbich <[email protected]>
@vmarchaud do @Flarna's fixes need to be applied to the plugin version too? |
No the original PR for the http plugin have the correct version, i'm not sure why my cherry-pick resulted in this. Even more surprised than neither typescript or tests had issues with this. |
Co-authored-by: Marc Pichler <[email protected]>
Co-authored-by: Marc Pichler <[email protected]>
Co-authored-by: Marc Pichler <[email protected]>
This is a pure copy/paste of the original commit with the exact same diff.
Fixes #1740