Remove boxed primitives from aggregations (#5184)
This commit is contained in:
parent
8f5ddf26e5
commit
7bb2f0d832
|
@ -350,8 +350,10 @@ class MetricsRequestMarshalerTest {
|
||||||
456,
|
456,
|
||||||
KV_ATTR,
|
KV_ATTR,
|
||||||
14.2,
|
14.2,
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
ImmutableList.of(1.0),
|
ImmutableList.of(1.0),
|
||||||
ImmutableList.of(1L, 5L)),
|
ImmutableList.of(1L, 5L)),
|
||||||
ImmutableHistogramPointData.create(
|
ImmutableHistogramPointData.create(
|
||||||
|
@ -359,7 +361,9 @@ class MetricsRequestMarshalerTest {
|
||||||
456,
|
456,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
15.3,
|
15.3,
|
||||||
|
/* hasMin= */ true,
|
||||||
3.3,
|
3.3,
|
||||||
|
/* hasMax= */ true,
|
||||||
12.0,
|
12.0,
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
ImmutableList.of(7L),
|
ImmutableList.of(7L),
|
||||||
|
@ -420,8 +424,10 @@ class MetricsRequestMarshalerTest {
|
||||||
0,
|
0,
|
||||||
123.4,
|
123.4,
|
||||||
1,
|
1,
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
ImmutableExponentialHistogramBuckets.create(0, 0, Collections.emptyList()),
|
ImmutableExponentialHistogramBuckets.create(0, 0, Collections.emptyList()),
|
||||||
ImmutableExponentialHistogramBuckets.create(0, 0, Collections.emptyList()),
|
ImmutableExponentialHistogramBuckets.create(0, 0, Collections.emptyList()),
|
||||||
123,
|
123,
|
||||||
|
@ -432,7 +438,9 @@ class MetricsRequestMarshalerTest {
|
||||||
0,
|
0,
|
||||||
123.4,
|
123.4,
|
||||||
1,
|
1,
|
||||||
|
/* hasMin= */ true,
|
||||||
3.3,
|
3.3,
|
||||||
|
/* hasMax= */ true,
|
||||||
80.1,
|
80.1,
|
||||||
ImmutableExponentialHistogramBuckets.create(
|
ImmutableExponentialHistogramBuckets.create(
|
||||||
0, 1, ImmutableList.of(1L, 0L, 2L)),
|
0, 1, ImmutableList.of(1L, 0L, 2L)),
|
||||||
|
@ -787,7 +795,9 @@ class MetricsRequestMarshalerTest {
|
||||||
456,
|
456,
|
||||||
KV_ATTR,
|
KV_ATTR,
|
||||||
4.0,
|
4.0,
|
||||||
|
/* hasMin= */ true,
|
||||||
1.0,
|
1.0,
|
||||||
|
/* hasMax= */ true,
|
||||||
3.0,
|
3.0,
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
ImmutableList.of(33L)))))))
|
ImmutableList.of(33L)))))))
|
||||||
|
@ -836,7 +846,9 @@ class MetricsRequestMarshalerTest {
|
||||||
20,
|
20,
|
||||||
123.4,
|
123.4,
|
||||||
257,
|
257,
|
||||||
|
/* hasMin= */ true,
|
||||||
20.1,
|
20.1,
|
||||||
|
/* hasMax= */ true,
|
||||||
44.3,
|
44.3,
|
||||||
ImmutableExponentialHistogramBuckets.create(
|
ImmutableExponentialHistogramBuckets.create(
|
||||||
20, -1, ImmutableList.of(0L, 128L, 1L << 32)),
|
20, -1, ImmutableList.of(0L, 128L, 1L << 32)),
|
||||||
|
|
|
@ -222,8 +222,10 @@ class SerializerTest {
|
||||||
1633950672000000000L,
|
1633950672000000000L,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
1.0,
|
1.0,
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.singletonList(2L),
|
Collections.singletonList(2L),
|
||||||
Collections.emptyList()))));
|
Collections.emptyList()))));
|
||||||
|
@ -245,8 +247,10 @@ class SerializerTest {
|
||||||
1633950672000000000L,
|
1633950672000000000L,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
1.0,
|
1.0,
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.singletonList(2L),
|
Collections.singletonList(2L),
|
||||||
Collections.singletonList(
|
Collections.singletonList(
|
||||||
|
@ -277,8 +281,10 @@ class SerializerTest {
|
||||||
1633950672000000000L,
|
1633950672000000000L,
|
||||||
Attributes.of(TYPE, "hs"),
|
Attributes.of(TYPE, "hs"),
|
||||||
1.0,
|
1.0,
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Collections.singletonList(2L),
|
Collections.singletonList(2L),
|
||||||
Collections.singletonList(
|
Collections.singletonList(
|
||||||
|
|
|
@ -236,8 +236,10 @@ public final class MetricAdapter {
|
||||||
endTimestamp,
|
endTimestamp,
|
||||||
attributes,
|
attributes,
|
||||||
distribution.getSum(),
|
distribution.getSum(),
|
||||||
null,
|
/* hasMin= */ false,
|
||||||
null,
|
0,
|
||||||
|
/* hasMax= */ false,
|
||||||
|
0,
|
||||||
mapBoundaries(distribution.getBucketOptions()),
|
mapBoundaries(distribution.getBucketOptions()),
|
||||||
mapCounts(distribution.getBuckets()),
|
mapCounts(distribution.getBuckets()),
|
||||||
mapExemplars(distribution.getBuckets())),
|
mapExemplars(distribution.getBuckets())),
|
||||||
|
|
|
@ -110,8 +110,10 @@ public final class DoubleBase2ExponentialHistogramAggregator
|
||||||
scale,
|
scale,
|
||||||
sum,
|
sum,
|
||||||
zeroCount,
|
zeroCount,
|
||||||
this.count > 0 ? this.min : null,
|
this.count > 0,
|
||||||
this.count > 0 ? this.max : null,
|
this.min,
|
||||||
|
this.count > 0,
|
||||||
|
this.max,
|
||||||
resolveBuckets(this.positiveBuckets, scale, reset),
|
resolveBuckets(this.positiveBuckets, scale, reset),
|
||||||
resolveBuckets(this.negativeBuckets, scale, reset),
|
resolveBuckets(this.negativeBuckets, scale, reset),
|
||||||
startEpochNanos,
|
startEpochNanos,
|
||||||
|
|
|
@ -133,8 +133,10 @@ public final class DoubleExplicitBucketHistogramAggregator
|
||||||
epochNanos,
|
epochNanos,
|
||||||
attributes,
|
attributes,
|
||||||
sum,
|
sum,
|
||||||
this.count > 0 ? this.min : null,
|
this.count > 0,
|
||||||
this.count > 0 ? this.max : null,
|
this.min,
|
||||||
|
this.count > 0,
|
||||||
|
this.max,
|
||||||
boundaryList,
|
boundaryList,
|
||||||
PrimitiveLongList.wrap(Arrays.copyOf(counts, counts.length)),
|
PrimitiveLongList.wrap(Arrays.copyOf(counts, counts.length)),
|
||||||
exemplars);
|
exemplars);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import io.opentelemetry.sdk.metrics.data.DoubleExemplarData;
|
||||||
import io.opentelemetry.sdk.metrics.data.ExponentialHistogramBuckets;
|
import io.opentelemetry.sdk.metrics.data.ExponentialHistogramBuckets;
|
||||||
import io.opentelemetry.sdk.metrics.data.ExponentialHistogramPointData;
|
import io.opentelemetry.sdk.metrics.data.ExponentialHistogramPointData;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,8 +36,10 @@ public abstract class ImmutableExponentialHistogramPointData
|
||||||
int scale,
|
int scale,
|
||||||
double sum,
|
double sum,
|
||||||
long zeroCount,
|
long zeroCount,
|
||||||
@Nullable Double min,
|
boolean hasMin,
|
||||||
@Nullable Double max,
|
double min,
|
||||||
|
boolean hasMax,
|
||||||
|
double max,
|
||||||
ExponentialHistogramBuckets positiveBuckets,
|
ExponentialHistogramBuckets positiveBuckets,
|
||||||
ExponentialHistogramBuckets negativeBuckets,
|
ExponentialHistogramBuckets negativeBuckets,
|
||||||
long startEpochNanos,
|
long startEpochNanos,
|
||||||
|
@ -56,10 +57,10 @@ public abstract class ImmutableExponentialHistogramPointData
|
||||||
sum,
|
sum,
|
||||||
count,
|
count,
|
||||||
zeroCount,
|
zeroCount,
|
||||||
min != null,
|
hasMin,
|
||||||
min != null ? min : -1,
|
min,
|
||||||
max != null,
|
hasMax,
|
||||||
max != null ? max : -1,
|
max,
|
||||||
positiveBuckets,
|
positiveBuckets,
|
||||||
negativeBuckets,
|
negativeBuckets,
|
||||||
exemplars);
|
exemplars);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import io.opentelemetry.sdk.metrics.data.HistogramPointData;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,13 +32,16 @@ public abstract class ImmutableHistogramPointData implements HistogramPointData
|
||||||
* @return a HistogramPointData.
|
* @return a HistogramPointData.
|
||||||
* @throws IllegalArgumentException if the given boundaries/counts were invalid
|
* @throws IllegalArgumentException if the given boundaries/counts were invalid
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("TooManyParameters")
|
||||||
public static ImmutableHistogramPointData create(
|
public static ImmutableHistogramPointData create(
|
||||||
long startEpochNanos,
|
long startEpochNanos,
|
||||||
long epochNanos,
|
long epochNanos,
|
||||||
Attributes attributes,
|
Attributes attributes,
|
||||||
double sum,
|
double sum,
|
||||||
@Nullable Double min,
|
boolean hasMin,
|
||||||
@Nullable Double max,
|
double min,
|
||||||
|
boolean hasMax,
|
||||||
|
double max,
|
||||||
List<Double> boundaries,
|
List<Double> boundaries,
|
||||||
List<Long> counts) {
|
List<Long> counts) {
|
||||||
return create(
|
return create(
|
||||||
|
@ -47,7 +49,9 @@ public abstract class ImmutableHistogramPointData implements HistogramPointData
|
||||||
epochNanos,
|
epochNanos,
|
||||||
attributes,
|
attributes,
|
||||||
sum,
|
sum,
|
||||||
|
hasMin,
|
||||||
min,
|
min,
|
||||||
|
hasMax,
|
||||||
max,
|
max,
|
||||||
boundaries,
|
boundaries,
|
||||||
counts,
|
counts,
|
||||||
|
@ -61,13 +65,16 @@ public abstract class ImmutableHistogramPointData implements HistogramPointData
|
||||||
* @return a HistogramPointData.
|
* @return a HistogramPointData.
|
||||||
* @throws IllegalArgumentException if the given boundaries/counts were invalid
|
* @throws IllegalArgumentException if the given boundaries/counts were invalid
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("TooManyParameters")
|
||||||
public static ImmutableHistogramPointData create(
|
public static ImmutableHistogramPointData create(
|
||||||
long startEpochNanos,
|
long startEpochNanos,
|
||||||
long epochNanos,
|
long epochNanos,
|
||||||
Attributes attributes,
|
Attributes attributes,
|
||||||
double sum,
|
double sum,
|
||||||
@Nullable Double min,
|
boolean hasMin,
|
||||||
@Nullable Double max,
|
double min,
|
||||||
|
boolean hasMax,
|
||||||
|
double max,
|
||||||
List<Double> boundaries,
|
List<Double> boundaries,
|
||||||
List<Long> counts,
|
List<Long> counts,
|
||||||
List<DoubleExemplarData> exemplars) {
|
List<DoubleExemplarData> exemplars) {
|
||||||
|
@ -96,10 +103,10 @@ public abstract class ImmutableHistogramPointData implements HistogramPointData
|
||||||
attributes,
|
attributes,
|
||||||
sum,
|
sum,
|
||||||
totalCount,
|
totalCount,
|
||||||
min != null,
|
hasMin,
|
||||||
min != null ? min : -1,
|
min,
|
||||||
max != null,
|
hasMax,
|
||||||
max != null ? max : -1,
|
max,
|
||||||
Collections.unmodifiableList(new ArrayList<>(boundaries)),
|
Collections.unmodifiableList(new ArrayList<>(boundaries)),
|
||||||
Collections.unmodifiableList(new ArrayList<>(counts)),
|
Collections.unmodifiableList(new ArrayList<>(counts)),
|
||||||
exemplars);
|
exemplars);
|
||||||
|
|
|
@ -63,7 +63,9 @@ class ImmutableMetricDataTest {
|
||||||
EPOCH_NANOS,
|
EPOCH_NANOS,
|
||||||
Attributes.of(KEY, "value"),
|
Attributes.of(KEY, "value"),
|
||||||
DOUBLE_VALUE,
|
DOUBLE_VALUE,
|
||||||
|
/* hasMin= */ true,
|
||||||
DOUBLE_VALUE_MIN,
|
DOUBLE_VALUE_MIN,
|
||||||
|
/* hasMax= */ true,
|
||||||
DOUBLE_VALUE_MAX,
|
DOUBLE_VALUE_MAX,
|
||||||
ImmutableList.of(1.0),
|
ImmutableList.of(1.0),
|
||||||
ImmutableList.of(1L, 1L));
|
ImmutableList.of(1L, 1L));
|
||||||
|
@ -203,7 +205,9 @@ class ImmutableMetricDataTest {
|
||||||
0,
|
0,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMin= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMax= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
ImmutableList.of(),
|
ImmutableList.of(),
|
||||||
ImmutableList.of()))
|
ImmutableList.of()))
|
||||||
|
@ -215,7 +219,9 @@ class ImmutableMetricDataTest {
|
||||||
0,
|
0,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMin= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMax= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
ImmutableList.of(1.0, 1.0),
|
ImmutableList.of(1.0, 1.0),
|
||||||
ImmutableList.of(0L, 0L, 0L)))
|
ImmutableList.of(0L, 0L, 0L)))
|
||||||
|
@ -227,7 +233,9 @@ class ImmutableMetricDataTest {
|
||||||
0,
|
0,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMin= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMax= */ false,
|
||||||
0.0,
|
0.0,
|
||||||
ImmutableList.of(Double.NEGATIVE_INFINITY),
|
ImmutableList.of(Double.NEGATIVE_INFINITY),
|
||||||
ImmutableList.of(0L, 0L)))
|
ImmutableList.of(0L, 0L)))
|
||||||
|
|
|
@ -76,7 +76,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
2175,
|
2175,
|
||||||
|
/* hasMin= */ true,
|
||||||
5d,
|
5d,
|
||||||
|
/* hasMax= */ true,
|
||||||
2000d,
|
2000d,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(1L, 1L, 1L, 1L)));
|
Arrays.asList(1L, 1L, 1L, 1L)));
|
||||||
|
@ -110,7 +112,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
0,
|
0,
|
||||||
|
/* hasMin= */ true,
|
||||||
0.0,
|
0.0,
|
||||||
|
/* hasMax= */ true,
|
||||||
0.0,
|
0.0,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(1L, 0L, 0L, 0L),
|
Arrays.asList(1L, 0L, 0L, 0L),
|
||||||
|
@ -131,7 +135,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
100,
|
100,
|
||||||
|
/* hasMin= */ true,
|
||||||
100d,
|
100d,
|
||||||
|
/* hasMax= */ true,
|
||||||
100d,
|
100d,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(0L, 1L, 0L, 0L)));
|
Arrays.asList(0L, 1L, 0L, 0L)));
|
||||||
|
@ -145,7 +151,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
0,
|
0,
|
||||||
|
/* hasMin= */ true,
|
||||||
0d,
|
0d,
|
||||||
|
/* hasMax= */ true,
|
||||||
0d,
|
0d,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(1L, 0L, 0L, 0L)));
|
Arrays.asList(1L, 0L, 0L, 0L)));
|
||||||
|
@ -191,7 +199,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
2,
|
2,
|
||||||
|
/* hasMin= */ true,
|
||||||
2d,
|
2d,
|
||||||
|
/* hasMax= */ true,
|
||||||
2d,
|
2d,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(1L, 0L, 0L, 0L),
|
Arrays.asList(1L, 0L, 0L, 0L),
|
||||||
|
@ -261,7 +271,9 @@ class DoubleExplicitBucketHistogramAggregatorTest {
|
||||||
1,
|
1,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
1010000,
|
1010000,
|
||||||
|
/* hasMin= */ true,
|
||||||
1d,
|
1d,
|
||||||
|
/* hasMax= */ true,
|
||||||
23d,
|
23d,
|
||||||
boundariesList,
|
boundariesList,
|
||||||
Arrays.asList(50000L, 50000L, 0L, 0L)));
|
Arrays.asList(50000L, 50000L, 0L, 0L)));
|
||||||
|
|
|
@ -207,7 +207,9 @@ class MetricAssertionsTest {
|
||||||
2,
|
2,
|
||||||
Attributes.empty(),
|
Attributes.empty(),
|
||||||
15,
|
15,
|
||||||
|
/* hasMin= */ true,
|
||||||
4.0,
|
4.0,
|
||||||
|
/* hasMax= */ true,
|
||||||
7.0,
|
7.0,
|
||||||
Collections.singletonList(10.0),
|
Collections.singletonList(10.0),
|
||||||
Arrays.asList(1L, 2L));
|
Arrays.asList(1L, 2L));
|
||||||
|
@ -241,7 +243,9 @@ class MetricAssertionsTest {
|
||||||
1,
|
1,
|
||||||
10.0,
|
10.0,
|
||||||
1,
|
1,
|
||||||
|
/* hasMin= */ true,
|
||||||
2.0,
|
2.0,
|
||||||
|
/* hasMax= */ true,
|
||||||
4.0,
|
4.0,
|
||||||
ImmutableExponentialHistogramBuckets.create(1, 10, Arrays.asList(1L, 2L)),
|
ImmutableExponentialHistogramBuckets.create(1, 10, Arrays.asList(1L, 2L)),
|
||||||
ImmutableExponentialHistogramBuckets.create(1, 0, Collections.emptyList()),
|
ImmutableExponentialHistogramBuckets.create(1, 0, Collections.emptyList()),
|
||||||
|
|
Loading…
Reference in New Issue