perf: cache clientMetadata lambda to avoid per-call allocation#1952
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors OpenFeatureClient to store a clientMetadata field initialized with a lambda reference in the constructor, returning it in getMetadata(). The reviewer suggests optimizing this further by having OpenFeatureClient directly implement the ClientMetadata interface, which would allow getMetadata() to return this and completely eliminate the extra field and lambda allocation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
8e1cd13 to
d66651c
Compare
|
Same codecov-action issue as #1955 (comment) - rebasing this PR onto main should fix it. cc @chrfwow |
Signed-off-by: Tobias Ibounig <tobias.ibounig@dynatrace.com>
d66651c to
12c0939
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1952 +/- ##
============================================
+ Coverage 92.25% 93.27% +1.01%
- Complexity 654 657 +3
============================================
Files 59 59
Lines 1589 1590 +1
Branches 179 179
============================================
+ Hits 1466 1483 +17
+ Misses 76 62 -14
+ Partials 47 45 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



This PR
ClientMetadatalambda in a final field to avoid re-allocating it on everygetMetadata()callRelated Issues
None
Notes
getMetadata()is called once per flag evaluation to build theSharedHookContext. Previously it returnedthis::getDomain— a new lambda instance each time. The field is initialized once in the constructor.Allocation impact is negligible, but reduces on
totalAllocatedInstancescan be seen.main(baseline)run:+totalAllocatedBytesrun:+totalAllocatedInstancesFollow-up Tasks