-
Notifications
You must be signed in to change notification settings - Fork 834
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
Memory Mode: Adding 2nd part support for synchronous instruments - exponential histogram #6058
Memory Mode: Adding 2nd part support for synchronous instruments - exponential histogram #6058
Conversation
…moryMode.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
…lder.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
…t1' into memory-mode-sync-instruments-part1
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6058 +/- ##
==========================================
Coverage 91.01% 91.01%
- Complexity 5702 5775 +73
==========================================
Files 630 634 +4
Lines 16710 16930 +220
Branches 1656 1693 +37
==========================================
+ Hits 15208 15409 +201
- Misses 1047 1049 +2
- Partials 455 472 +17 ☔ View full report in Codecov by Sentry. |
@asafm is this ready for review? |
I'll give it one more pass, fill the description and I'll ping you . |
@jack-berg Ready for review now. I've added a detailed overview of what was added in the PR, so it's good to read this first before diving into the code 🙏 |
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.
Looks pretty good to me! Just a handful of minor comments.
sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/view/SumAggregation.java
Outdated
Show resolved
Hide resolved
...in/java/io/opentelemetry/sdk/metrics/internal/data/MutableExponentialHistogramPointData.java
Outdated
Show resolved
Hide resolved
...ava/io/opentelemetry/sdk/metrics/internal/aggregator/MutableExponentialHistogramBuckets.java
Outdated
Show resolved
Hide resolved
.../java/io/opentelemetry/sdk/metrics/internal/aggregator/EmptyExponentialHistogramBuckets.java
Outdated
Show resolved
Hide resolved
...opentelemetry/sdk/metrics/internal/aggregator/DoubleBase2ExponentialHistogramAggregator.java
Show resolved
Hide resolved
exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/Serializer.java
Show resolved
Hide resolved
sdk/common/src/main/java/io/opentelemetry/sdk/internal/DynamicPrimitiveLongList.java
Outdated
Show resolved
Hide resolved
sdk/common/src/main/java/io/opentelemetry/sdk/internal/DynamicPrimitiveLongList.java
Outdated
Show resolved
Hide resolved
sdk/common/src/main/java/io/opentelemetry/sdk/internal/DynamicPrimitiveLongList.java
Show resolved
Hide resolved
sdk/common/src/test/java/io/opentelemetry/sdk/internal/DynamicPrimitiveLongListTest.java
Outdated
Show resolved
Hide resolved
@jack-berg Thanks for the review. I fixed all but one comment, which I didn't know what to do. I replied to it. |
@jack-berg I pushed the fix to all remaining comments. |
@jack-berg How do you rebuild the markdown links check? |
Thanks! @open-telemetry/java-approvers I'll plan on merging this in on 1/10/24 unless anyone indicates they plan on reviewing. |
Epic
This is the 3rd PR out of several that implement #5105. See the complete plan here.
What was done here?
Added support for
MemoryMode
- specificallyREUSABLE_DATA
- for Exponential Histogram.DynamicPrimitiveLongList
, which replacesPrimitiveLongList
for REUSABLE_DATA mode. It allows accessing the primitive values throughlong getLong(i)
andsetLong(i,longValue)
DynamicPrimitiveLongList
AggregatorFactory
now has a requiredMemoryMode
parameter, enabling the aggregator factories to relay the memory mode used by theMetricsReader
to the Aggregator classes, as they need to behave differently upon the memory mode. Specifically, in this PR, onlyDoubleBase2ExponentialHistogramAggregator
takes it into account. Future PRs will augment all otherAggregator
s classes. They have all been modified, but are currently ignoring this value.DoubleBase2ExponentialHistogramAggregator
has been changed to supportREUSABLE_DATA
. In that memory mode, the point returned by the aggregation indoAggregateThenMaybeReset()
is now a reusableMutableExponentialHistogramPointData
. We create this point instance once upon initialization, and then setting all of its values and returning it as a result. We know it is safe, since theMetricsReader
implementations which support REUSABLE_DATA knows that the list of data point received can not be used concurrently.MutableExponentialHistogramPointData
fields are rather simple like the immutable version, aside from theExponentialHistogramBuckets
ones: the positive and the negative. Here, as well, we had to create a mutable version calledMutableExponentialHistogramBuckets
.MutableExponentialHistogramBuckets
from the reusable point, and simply set the values, retrieved from theDoubleBase2ExponentialHistogramBuckets
likescale
,offset
andtotalCount
. The biggest difference is how we retrieve the bucket counts. In the mutable version, the bucket counts were aList<Long>
, which behind the scenes was an implementation ofList<Long>
holding an array of primitive longs - immutable and not-resizable.In the mutable version, the bucket counts are stored in
DynamicPrimitiveLongList
, which grow in size when needed (i.e. bucket count changes).DoubleBase2ExponentialHistogramBuckets
now has a method that returns the bucket counts into a reusableDynamicPrimitiveLongList
.DoubleBase2ExponentialHistogramBuckets
is the place we keep and update the bucket counts. In the immutable version, we kept allocating a newAdaptingCircularBufferCounter
each time the number of bucket changed - inside it meant allocating a new array with fixed size ofmaxBuckets
. Now in the mutable version, we have an additional instance ofAdaptingCircularBufferCounter
we keep, and we reuse it. Each time we need to change the number of buckets, we do it on the inactiveAdaptingCircularBufferCounter
instance, and then swap them.EmptyExponentialHistogramBuckets
into its own file, since I needed to use it atMutableExponentialHistogramPointData
, when I initialize the positive and negative buckets. This is to avoid using null, hence consistent with other mutable classes.Next PRs