Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asafm committed Jan 9, 2024
1 parent 95690f1 commit 6a124c5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.metrics.internal.data;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.sdk.internal.DynamicPrimitiveLongList;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class MutableExponentialHistogramBucketsTest {

@Test
Expand All @@ -16,7 +21,7 @@ void testSanity() {
assertThat(buckets.getBucketCounts()).isEmpty();
assertThat(buckets.getReusableBucketCountsList()).isEmpty();

DynamicPrimitiveLongList bucketCounts = DynamicPrimitiveLongList.of(1,2,3);
DynamicPrimitiveLongList bucketCounts = DynamicPrimitiveLongList.of(1, 2, 3);
buckets.set(1, 2, 3, bucketCounts);

assertThat(buckets.getScale()).isEqualTo(1);
Expand All @@ -26,10 +31,12 @@ void testSanity() {
assertThat(buckets.getReusableBucketCountsList()).containsExactly(1L, 2L, 3L);

MutableExponentialHistogramBuckets sameBuckets = new MutableExponentialHistogramBuckets();
sameBuckets.set(1, 2, 3, DynamicPrimitiveLongList.of(1,2,3));
sameBuckets.set(1, 2, 3, DynamicPrimitiveLongList.of(1, 2, 3));
assertThat(sameBuckets).isEqualTo(buckets);
assertThat(sameBuckets.hashCode()).isEqualTo(buckets.hashCode());

assertThat(buckets.toString()).isEqualTo("MutableExponentialHistogramBuckets{scale=1, offset=2, bucketCounts=[1, 2, 3], totalCount=3}");
assertThat(buckets.toString())
.isEqualTo(
"MutableExponentialHistogramBuckets{scale=1, offset=2, bucketCounts=[1, 2, 3], totalCount=3}");
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.sdk.metrics.internal.data;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.internal.DynamicPrimitiveLongList;
import org.junit.jupiter.api.Test;

import java.util.Collections;

import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;

class MutableExponentialHistogramPointDataTest {

Expand All @@ -21,26 +25,28 @@ public void testSanity() {
assertThat(pointData.getExemplars()).isEmpty();

MutableExponentialHistogramBuckets positiveBuckets = new MutableExponentialHistogramBuckets();
positiveBuckets.set(/* scale= */1, /* offset= */2, /* totalCount= */3,
DynamicPrimitiveLongList.of(1, 2, 3));
positiveBuckets.set(
/* scale= */ 1, /* offset= */ 2, /* totalCount= */ 3, DynamicPrimitiveLongList.of(1, 2, 3));
MutableExponentialHistogramBuckets negativeBuckets = new MutableExponentialHistogramBuckets();
negativeBuckets.set(10, 20, 30, DynamicPrimitiveLongList.of(50, 60, 70));

pointData.set(
/* scale= */1,
/* sum= */2,
/* zeroCount= */10,
/* hasMin= */true,
/* min= */100,
/* hasMax= */true,
/* max= */1000, positiveBuckets, negativeBuckets,
/* startEpochNanos= */10,
/* epochNanos= */20,
/* scale= */ 1,
/* sum= */ 2,
/* zeroCount= */ 10,
/* hasMin= */ true,
/* min= */ 100,
/* hasMax= */ true,
/* max= */ 1000,
positiveBuckets,
negativeBuckets,
/* startEpochNanos= */ 10,
/* epochNanos= */ 20,
Attributes.of(AttributeKey.stringKey("foo"), "bar"),
Collections.emptyList());

assertThat(pointData.getSum()).isEqualTo(2);
assertThat(pointData.getCount()).isEqualTo(10+30+3);
assertThat(pointData.getCount()).isEqualTo(10 + 30 + 3);
assertThat(pointData.getAttributes().get(AttributeKey.stringKey("foo"))).isEqualTo("bar");
assertThat(pointData.getAttributes().size()).isEqualTo(1);
assertThat(pointData.getScale()).isEqualTo(1);
Expand All @@ -57,28 +63,29 @@ public void testSanity() {
assertThat(pointData.getEpochNanos()).isEqualTo(20);
assertThat(pointData.getExemplars()).isEmpty();

assertThat(pointData.toString()).isEqualTo(
"MutableExponentialHistogramPointData{startEpochNanos=10, epochNanos=20, "
+ "attributes={foo=\"bar\"}, scale=1, sum=2.0, count=43, zeroCount=10, hasMin=true, "
+ "min=100.0, hasMax=true, max=1000.0, "
+ "positiveBuckets=MutableExponentialHistogramBuckets{scale=1, offset=2, "
+ "bucketCounts=[1, 2, 3], totalCount=3}, "
+ "negativeBuckets=MutableExponentialHistogramBuckets{scale=10, offset=20, "
+ "bucketCounts=[50, 60, 70], totalCount=30}, exemplars=[]}"
);

assertThat(pointData.toString())
.isEqualTo(
"MutableExponentialHistogramPointData{startEpochNanos=10, epochNanos=20, "
+ "attributes={foo=\"bar\"}, scale=1, sum=2.0, count=43, zeroCount=10, hasMin=true, "
+ "min=100.0, hasMax=true, max=1000.0, "
+ "positiveBuckets=MutableExponentialHistogramBuckets{scale=1, offset=2, "
+ "bucketCounts=[1, 2, 3], totalCount=3}, "
+ "negativeBuckets=MutableExponentialHistogramBuckets{scale=10, offset=20, "
+ "bucketCounts=[50, 60, 70], totalCount=30}, exemplars=[]}");

MutableExponentialHistogramPointData samePointData = new MutableExponentialHistogramPointData();
samePointData.set(
/* scale= */1,
/* sum= */2,
/* zeroCount= */10,
/* hasMin= */true,
/* min= */100,
/* hasMax= */true,
/* max= */1000, positiveBuckets, negativeBuckets,
/* startEpochNanos= */10,
/* epochNanos= */20,
/* scale= */ 1,
/* sum= */ 2,
/* zeroCount= */ 10,
/* hasMin= */ true,
/* min= */ 100,
/* hasMax= */ true,
/* max= */ 1000,
positiveBuckets,
negativeBuckets,
/* startEpochNanos= */ 10,
/* epochNanos= */ 20,
Attributes.of(AttributeKey.stringKey("foo"), "bar"),
Collections.emptyList());
assertThat(samePointData).isEqualTo(pointData);
Expand Down

0 comments on commit 6a124c5

Please sign in to comment.