Bound instruments#8527
Open
jack-berg wants to merge 5 commits into
Open
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (74.48%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8527 +/- ##
============================================
- Coverage 78.51% 78.46% -0.06%
- Complexity 8601 8666 +65
============================================
Files 1013 1013
Lines 29148 29416 +268
Branches 3631 3655 +24
============================================
+ Hits 22887 23081 +194
- Misses 5420 5478 +58
- Partials 841 857 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Supersedes #8314.
Java implementation of open-telemetry/opentelemetry-specification#5050
Adds bound instrument support to
opentelemetry-api-incubator. Usage:In the original prototype #8314, I went with an API where bind returns the existing instrument interface. I.e. you call
LongCounter bind(Attributes)fromLongCounter. The user is meant to calladd(long), but the other methodsbind/add(long, Attributes),add(long, Attributes, Context)are still available. The user could call bind again without issue, but calling the add overloads which accept Attributes remove the performance gain.Instead, in this PR I've added dedicated
Bound{Type}{Instrument}interfaces, e.g:These are impossible to misuse, and allows for supporting a value + Context overload. Additionally, they lend themselves to extending later with a
close()method. Something that cannot be reasonably done if we reuse the existing instrument interfaces because whereas calling close on a bound instrument should only close that series, calling close on the instrument should either close all the series or have some sort of selector for the series that should be closed. The semantics are too different to reuse.In the original prototype #8314 I sketched out what it would look like in its final form with APIs added directly to the stable
opentelemetry-api. Here I've added it to the incubator such that its actually in a position to merge and evaluate.Performance characteristics
Main vs. PR - unbound instruments
No material change in performance. All changes are within variance.
Details
Bound vs. unbound instruments
Big improvement in uncontended cases. Mixed results with contention.
Bound instruments remove a map lookup. This is great on paper, but in practice, the CMH is meticulously engineered such that it's not the main point of contention. When the map lookup is removed, the other points of contention (i.e. AtomicInteger used to coordinate between record / collect threads for delta, and LongAdder used to actually accumulate values) get put under more pressure, which reduces performance.
To improve, we need to look to improving the concurrent throughput of the new hotspots. Probably possible, but not easy. That work can be done in a followup because:
Details