refactor(instrumentation-http): refactor getIncomingRequestAttributes() to reduce work#6207
Merged
maryliag merged 4 commits intoopen-telemetry:mainfrom Dec 18, 2025
Merged
Conversation
…() to reduce work
cjihrig
commented
Dec 10, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6207 +/- ##
=======================================
Coverage 95.40% 95.40%
=======================================
Files 317 317
Lines 9514 9514
Branches 2192 2192
=======================================
Hits 9077 9077
Misses 437 437 🚀 New features to boost your workflow:
|
Contributor
Author
|
Maybe ping @maryliag who had originally asked me to look into potential perf improvements? |
maryliag
approved these changes
Dec 18, 2025
Contributor
maryliag
left a comment
There was a problem hiding this comment.
Nice improvement! Thank you for working on this!
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
getIncomingRequestAttributes()is on the stack 12% of the time in a flame graph I created for an HTTP server. Since this function is somewhat hot, it makes sense to optimize it a bit. More specifically, this function is computing two sets of attributes even though often only a single set of attributes is needed.Fixes # N/A
Short description of the changes
This commit updates
getIncomingRequestAttributes()to only compute the necessary attributes. On my local macOS machine running Node 25, this reduced the amount of time it was on the stack from 12% to 7%. The number of requests served also went from 372k to 390k (for more context, this was at 1350k requests for the same Node server without any OTel).Type of change
None of these - performance refactor.
How Has This Been Tested?
Checklist: