-
Notifications
You must be signed in to change notification settings - Fork 850
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
Optimize log hot path #4913
Optimize log hot path #4913
Conversation
…entationScopeInfo
Codecov ReportBase: 90.89% // Head: 90.93% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #4913 +/- ##
============================================
+ Coverage 90.89% 90.93% +0.03%
- Complexity 4804 4816 +12
============================================
Files 545 545
Lines 14340 14382 +42
Branches 1383 1382 -1
============================================
+ Hits 13035 13078 +43
Misses 898 898
+ Partials 407 406 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
Awesome! 🚀
sdk/common/src/main/java/io/opentelemetry/sdk/internal/ComponentRegistry.java
Outdated
Show resolved
Hide resolved
No real problem with this optimization, but is this really on the hot path? Shouldn't people be initializing their loggers/tracers/etc once, rather than fetching them every time? |
With tracers and meters, yes. But log appender implementations use the logger name as the name of the logger, so they have to get a logger for each log record they process. Here's an example from the log4j appender. The logback and jul implementations work the same way. The appenders could implement their own cache of loggers by maintaining a map of logger name to logger, but if that's a pattern all implementations will have to do we should probably solve it in the SDK. |
ah, I see. for the appender case, that makes sense. thanks! |
* ComponentRegistry accepts name, version, schemaUrl instead of InstrumentationScopeInfo * Fix comment
Followup to #4891.
Reduces allocations on happy path by avoiding creation of extra
InstrumentationScopeInfo
/InstrumentationScopeInfoBuilder
instances that aren't strictly needed. Does this by adjusting changingComponentRegistry#get(InstrumentationScopeInfo)
toComponentRegistry#get(String name, @Nullable String version, @Nullable String schemaUrl, Attributes attributes)
, and only buildingInstrumentationScopeInfo
the first time we see a component with a particular identity.Benchmark before:
Benchmark after:
Notice the significant reduction in allocation rate.