-
Notifications
You must be signed in to change notification settings - Fork 97
Instrumentation/HTTP: Handle incoming requests with long request url … #515
Instrumentation/HTTP: Handle incoming requests with long request url … #515
Conversation
Codecov Report
@@ Coverage Diff @@
## master #515 +/- ##
==========================================
+ Coverage 94.81% 95.17% +0.35%
==========================================
Files 147 147
Lines 10604 10582 -22
Branches 905 899 -6
==========================================
+ Hits 10054 10071 +17
+ Misses 550 511 -39
Continue to review full report at Codecov.
|
I'm not sure if they are other places where we set tag value that may be above the 256 length mark. |
Other places are for |
@@ -228,7 +228,12 @@ export class HttpPlugin extends BasePlugin { | |||
rootSpan.addAttribute( | |||
HttpPlugin.ATTRIBUTE_HTTP_ROUTE, requestUrl.path || ''); | |||
tags.set( | |||
stats.HTTP_SERVER_ROUTE, {value: requestUrl.path || ''}, | |||
stats.HTTP_SERVER_ROUTE, { | |||
value: ((requestUrl.path && requestUrl.path.length > 255) ? |
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.
Can this be simplified to just (requestUrl.path || '').substring(0, 255)
?
Calling substring on a shorter string just returns the string so for strings shorter than 255 that is fine.
Should 255 be a constant as well?
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.
Sure, done. I was thinking not to use substring
unless it is really required by checking the 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.
Makes sense - I'd say either is fine. I'm not sure whether the substring
has a performance/memory penalty, but if it did that seems like a reason to only do it if needed.
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.
Not sure, already made the change as per your suggestion.
c6834ba
to
9d5cb11
Compare
…path
Fixes #486