PoC: Add experimental support for bound sum instruments#8278
Draft
dashpole wants to merge 1 commit intoopen-telemetry:mainfrom
Draft
PoC: Add experimental support for bound sum instruments#8278dashpole wants to merge 1 commit intoopen-telemetry:mainfrom
dashpole wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8278 +/- ##
=======================================
- Coverage 82.9% 82.8% -0.1%
=======================================
Files 314 314
Lines 24911 25209 +298
=======================================
+ Hits 20661 20889 +228
- Misses 3878 3937 +59
- Partials 372 383 +11
🚀 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 #7790
This implements a PoC for open-telemetry/opentelemetry-specification#5050, with some divergences (to try and make this more ergonomic):
metric.Float64Counter, which has an Add function that also accepts attributes. The current proposal does not allow the Add function for a bound instrument to also accept attributes.Differences compared to the previous prototype:
metric/xinstead of inmetricto avoid public API changes.This prototype does not implement bound instruments for all instrument types (only for counters).
Benchmarks:
Note: I removed Filtered, Naive, and WithAttributes, and the 5 attribute case to make the benchmarks legible.
Overall, Bind() and Add() have zero memory allocations as long as there is a single measurement function (i.e. you don't have multiple views defined for the same instrument).
The Precomputed case, in which the attributes are known ahead of time, the runtime is very close to the underlying performance of incrementing an atomic counter on my machine (3 ns with no contention, ~25 ns) with 24 cores. In the Dynamic case, where attributes need to be computed for each call, the additional runtime cost is from hashing the incoming attributes, and performing the map lookup.
Serial Benchmarks:
Most of this was written by Gemini.