From c21751c09a885b7fe1c8fced46fb45dd52b2e0bf Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Tue, 26 Sep 2023 14:56:09 -0500 Subject: [PATCH 1/2] Cleanup a few typos --- .../sdk/metrics/export/MetricExporter.java | 2 +- .../sdk/metrics/export/MetricReader.java | 2 +- .../internal/state/ArrayBasedStack.java | 3 +- .../internal/state/MutableMeasurement.java | 2 +- .../metrics/internal/state/ObjectPool.java | 2 +- .../metrics/internal/state/PooledHashMap.java | 2 +- .../DoubleLastValueAggregatorTest.java | 11 +++--- .../aggregator/DoubleSumAggregatorTest.java | 19 +++++---- .../LongLastValueAggregatorTest.java | 15 +++---- .../aggregator/LongSumAggregatorTest.java | 25 ++++++------ .../state/AsynchronousMetricStorageTest.java | 2 +- .../internal/state/PooledHashMapTest.java | 39 ++++++++++--------- sdk/metrics/testing-internal/build.gradle.kts | 13 ------- .../exporter/InMemoryMetricReader.java | 2 +- .../exporter/InMemoryMetricReaderBuilder.java | 18 ++++++++- 15 files changed, 77 insertions(+), 80 deletions(-) delete mode 100644 sdk/metrics/testing-internal/build.gradle.kts diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricExporter.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricExporter.java index f4f8f569055..685c5f09bf1 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricExporter.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricExporter.java @@ -45,7 +45,7 @@ default Aggregation getDefaultAggregation(InstrumentType instrumentType) { * Returns the memory mode used by this exporter's associated reader. * * @return The {@link MemoryMode} used by this exporter's associated reader - * @since 1.29.0 + * @since 1.31.0 */ default MemoryMode getMemoryMode() { return IMMUTABLE_DATA; diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricReader.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricReader.java index 0b0fb974d78..4ff4155f9bd 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricReader.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricReader.java @@ -51,7 +51,7 @@ default Aggregation getDefaultAggregation(InstrumentType instrumentType) { * Returns the memory mode used by this reader. * * @return The {@link MemoryMode} used by this instance - * @since 1.29.0 + * @since 1.31.0 */ default MemoryMode getMemoryMode() { return IMMUTABLE_DATA; diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ArrayBasedStack.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ArrayBasedStack.java index 627955b3403..907ec7e2234 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ArrayBasedStack.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ArrayBasedStack.java @@ -15,7 +15,8 @@ * *

This class is not thread-safe. */ -public class ArrayBasedStack { +public final class ArrayBasedStack { + // Visible for test static final int DEFAULT_CAPACITY = 10; // NOTE (asafm): Using native array instead of ArrayList since I plan to add eviction diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MutableMeasurement.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MutableMeasurement.java index 9c88712d487..7bac8202447 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MutableMeasurement.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/MutableMeasurement.java @@ -15,7 +15,7 @@ * *

This class is not thread-safe. */ -public class MutableMeasurement implements Measurement { +public final class MutableMeasurement implements Measurement { static void setDoubleMeasurement( MutableMeasurement mutableMeasurement, diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ObjectPool.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ObjectPool.java index 3a129613d87..8be6abcb5dd 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ObjectPool.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/ObjectPool.java @@ -20,7 +20,7 @@ * *

This class is not thread-safe. */ -public class ObjectPool { +public final class ObjectPool { private final ArrayBasedStack pool; private final Supplier objectCreator; diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMap.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMap.java index 452ed9d50ea..2a9bfd8cc6b 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMap.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMap.java @@ -35,7 +35,7 @@ * @param The map value type */ @SuppressWarnings("ForLoopReplaceableByForEach") -public class PooledHashMap implements Map { +public final class PooledHashMap implements Map { private static final int DEFAULT_CAPACITY = 16; private static final float LOAD_FACTOR = 0.75f; diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregatorTest.java index fa0dd75caa4..5f7a276e1e9 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleLastValueAggregatorTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.sdk.metrics.internal.aggregator; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -25,7 +26,6 @@ import io.opentelemetry.sdk.resources.Resource; import java.util.Collections; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; /** Unit tests for {@link AggregatorHandle}. */ @@ -194,12 +194,11 @@ void copyPoint() { aggregator.copyPoint(pointData, toPointData); - Assertions.assertThat(toPointData.getStartEpochNanos()) - .isEqualTo(pointData.getStartEpochNanos()); - Assertions.assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); + assertThat(toPointData.getStartEpochNanos()).isEqualTo(pointData.getStartEpochNanos()); + assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); - Assertions.assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); - Assertions.assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); + assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); + assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); } @Test diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregatorTest.java index 06651798bf2..edd1f0fc077 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/DoubleSumAggregatorTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.sdk.metrics.internal.aggregator; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -30,7 +31,6 @@ import io.opentelemetry.sdk.resources.Resource; import java.util.Collections; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -228,11 +228,11 @@ void diffInPlace() { aggregator.diffInPlace(previous, current); /* Assert that latest measurement is kept and set on {@code previous} */ - Assertions.assertThat(previous.getStartEpochNanos()).isEqualTo(current.getStartEpochNanos()); - Assertions.assertThat(previous.getEpochNanos()).isEqualTo(current.getEpochNanos()); + assertThat(previous.getStartEpochNanos()).isEqualTo(current.getStartEpochNanos()); + assertThat(previous.getEpochNanos()).isEqualTo(current.getEpochNanos()); assertThat(previous.getAttributes()).isEqualTo(current.getAttributes()); - Assertions.assertThat(previous.getValue()).isEqualTo(2); - Assertions.assertThat(previous.getExemplars()).isEqualTo(exemplars); + assertThat(previous.getValue()).isEqualTo(2); + assertThat(previous.getExemplars()).isEqualTo(exemplars); } @Test @@ -271,12 +271,11 @@ void copyPoint() { aggregator.copyPoint(pointData, toPointData); - Assertions.assertThat(toPointData.getStartEpochNanos()) - .isEqualTo(pointData.getStartEpochNanos()); - Assertions.assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); + assertThat(toPointData.getStartEpochNanos()).isEqualTo(pointData.getStartEpochNanos()); + assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); - Assertions.assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); - Assertions.assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); + assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); + assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); } @Test diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java index e7d4140309f..266638dfc46 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java @@ -25,7 +25,6 @@ import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.metrics.internal.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.util.Collections; import java.util.List; import org.assertj.core.api.Assertions; @@ -120,7 +119,7 @@ void diffInPlace() { /* Assert that latest measurement is kept and set on {@code previous} */ assertThat(previous.getStartEpochNanos()).isEqualTo(0); assertThat(previous.getEpochNanos()).isEqualTo(1); - OpenTelemetryAssertions.assertThat(previous.getAttributes()).isEqualTo(Attributes.empty()); + Assertions.assertThat(previous.getAttributes()).isEqualTo(Attributes.empty()); assertThat(previous.getValue()).isEqualTo(2); assertThat(previous.getExemplars()).isEqualTo(exemplars); } @@ -161,13 +160,11 @@ void copyPoint() { aggregator.copyPoint(pointData, toPointData); - Assertions.assertThat(toPointData.getStartEpochNanos()) - .isEqualTo(pointData.getStartEpochNanos()); - Assertions.assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); - OpenTelemetryAssertions.assertThat(toPointData.getAttributes()) - .isEqualTo(pointData.getAttributes()); - Assertions.assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); - Assertions.assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); + assertThat(toPointData.getStartEpochNanos()).isEqualTo(pointData.getStartEpochNanos()); + assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); + Assertions.assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); + assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); + assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); } @Test diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java index 81e6f40a8b7..6cd58796f8f 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java @@ -6,6 +6,7 @@ package io.opentelemetry.sdk.metrics.internal.aggregator; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; +import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -28,10 +29,8 @@ import io.opentelemetry.sdk.metrics.internal.descriptor.MetricDescriptor; import io.opentelemetry.sdk.metrics.internal.exemplar.ExemplarReservoir; import io.opentelemetry.sdk.resources.Resource; -import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions; import java.util.Collections; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -223,11 +222,11 @@ void diffInPlace() { aggregator.diffInPlace(previous, current); /* Assert that latest measurement is kept and set on {@code previous} */ - Assertions.assertThat(previous.getStartEpochNanos()).isEqualTo(current.getStartEpochNanos()); - Assertions.assertThat(previous.getEpochNanos()).isEqualTo(current.getEpochNanos()); - OpenTelemetryAssertions.assertThat(previous.getAttributes()).isEqualTo(current.getAttributes()); - Assertions.assertThat(previous.getValue()).isEqualTo(2); - Assertions.assertThat(previous.getExemplars()).isEqualTo(current.getExemplars()); + assertThat(previous.getStartEpochNanos()).isEqualTo(current.getStartEpochNanos()); + assertThat(previous.getEpochNanos()).isEqualTo(current.getEpochNanos()); + assertThat(previous.getAttributes()).isEqualTo(current.getAttributes()); + assertThat(previous.getValue()).isEqualTo(2); + assertThat(previous.getExemplars()).isEqualTo(current.getExemplars()); } @Test @@ -266,13 +265,11 @@ void copyPoint() { aggregator.copyPoint(pointData, toPointData); - Assertions.assertThat(toPointData.getStartEpochNanos()) - .isEqualTo(pointData.getStartEpochNanos()); - Assertions.assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); - OpenTelemetryAssertions.assertThat(toPointData.getAttributes()) - .isEqualTo(pointData.getAttributes()); - Assertions.assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); - Assertions.assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); + assertThat(toPointData.getStartEpochNanos()).isEqualTo(pointData.getStartEpochNanos()); + assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); + assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); + assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); + assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); } @Test diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorageTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorageTest.java index 109b8eef7a4..23c45a9349f 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorageTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/AsynchronousMetricStorageTest.java @@ -378,7 +378,7 @@ void collect_DeltaComputesDiff(MemoryMode memoryMode) { } @Test - public void collect_reusableData_reusedObjectsAreReturnedOnSecondCall() { + void collect_reusableData_reusedObjectsAreReturnedOnSecondCall() { setup(REUSABLE_DATA); longCounterStorage.record(createLong(0, 1, 1, Attributes.builder().put("key", "a").build())); diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMapTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMapTest.java index f53aec03f90..0e4a5ab0328 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMapTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/PooledHashMapTest.java @@ -5,71 +5,72 @@ package io.opentelemetry.sdk.metrics.internal.state; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.HashMap; import java.util.Map; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class PooledHashMapTest { +class PooledHashMapTest { private PooledHashMap map; @BeforeEach - public void setup() { + void setup() { map = new PooledHashMap<>(); } @Test - public void putAndGetTest() { + void putAndGetTest() { map.put("One", 1); - Assertions.assertThat(map.get("One")).isEqualTo(1); + assertThat(map.get("One")).isEqualTo(1); } @Test - public void removeTest() { + void removeTest() { map.put("One", 1); map.remove("One"); - Assertions.assertThat(map.get("One")).isNull(); + assertThat(map.get("One")).isNull(); } @Test - public void sizeTest() { + void sizeTest() { map.put("One", 1); map.put("Two", 2); - Assertions.assertThat(map.size()).isEqualTo(2); + assertThat(map.size()).isEqualTo(2); } @Test - public void isEmptyTest() { - Assertions.assertThat(map.isEmpty()).isTrue(); + void isEmptyTest() { + assertThat(map.isEmpty()).isTrue(); map.put("One", 1); - Assertions.assertThat(map.isEmpty()).isFalse(); + assertThat(map.isEmpty()).isFalse(); } @Test - public void containsKeyTest() { + void containsKeyTest() { map.put("One", 1); - Assertions.assertThat(map.containsKey("One")).isTrue(); - Assertions.assertThat(map.containsKey("Two")).isFalse(); + assertThat(map.containsKey("One")).isTrue(); + assertThat(map.containsKey("Two")).isFalse(); } @Test - public void clearTest() { + void clearTest() { map.put("One", 1); map.put("Two", 2); map.clear(); - Assertions.assertThat(map.isEmpty()).isTrue(); + assertThat(map.isEmpty()).isTrue(); } @Test - public void forEachTest() { + void forEachTest() { map.put("One", 1); map.put("Two", 2); Map actualMap = new HashMap<>(); map.forEach(actualMap::put); - Assertions.assertThat(actualMap).containsOnlyKeys("One", "Two").containsValues(1, 2); + assertThat(actualMap).containsOnlyKeys("One", "Two").containsValues(1, 2); } } diff --git a/sdk/metrics/testing-internal/build.gradle.kts b/sdk/metrics/testing-internal/build.gradle.kts deleted file mode 100644 index df76bebe8fb..00000000000 --- a/sdk/metrics/testing-internal/build.gradle.kts +++ /dev/null @@ -1,13 +0,0 @@ -plugins { - id("otel.java-conventions") -} - -description = "OpenTelemetry Metrics Testing (Internal)" -otelJava.moduleName.set("io.opentelemetry.metrics.internal.testing") - -dependencies { - api("org.junit.jupiter:junit-jupiter-api") - implementation("org.slf4j:jul-to-slf4j") - api(project(":sdk:common")) - api(project(":sdk:metrics")) -} diff --git a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReader.java b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReader.java index d9aa8bfb3c5..e72a78c52ee 100644 --- a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReader.java +++ b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReader.java @@ -62,7 +62,7 @@ public class InMemoryMetricReader implements MetricReader { * * @return a builder with always-cumulative {@link AggregationTemporalitySelector}, default {@link * DefaultAggregationSelector} and {@link MemoryMode#IMMUTABLE_DATA} {@link MemoryMode} - * @since 1.29.0 + * @since 1.31.0 */ public static InMemoryMetricReaderBuilder builder() { return new InMemoryMetricReaderBuilder(); diff --git a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReaderBuilder.java b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReaderBuilder.java index e3824e6cae7..8a0c934bb2d 100644 --- a/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReaderBuilder.java +++ b/sdk/testing/src/main/java/io/opentelemetry/sdk/testing/exporter/InMemoryMetricReaderBuilder.java @@ -8,9 +8,16 @@ import static io.opentelemetry.sdk.common.export.MemoryMode.IMMUTABLE_DATA; import io.opentelemetry.sdk.common.export.MemoryMode; +import io.opentelemetry.sdk.metrics.InstrumentType; import io.opentelemetry.sdk.metrics.export.AggregationTemporalitySelector; import io.opentelemetry.sdk.metrics.export.DefaultAggregationSelector; +import io.opentelemetry.sdk.metrics.export.MetricExporter; +/** + * Builder for {@link InMemoryMetricReader}. + * + * @since 1.31.0 + */ public final class InMemoryMetricReaderBuilder { private AggregationTemporalitySelector aggregationTemporalitySelector = AggregationTemporalitySelector.alwaysCumulative(); @@ -26,6 +33,13 @@ public final class InMemoryMetricReaderBuilder { */ InMemoryMetricReaderBuilder() {} + /** + * Sets the {@link AggregationTemporalitySelector} used by {@link + * MetricExporter#getAggregationTemporality(InstrumentType)}. + * + * @param aggregationTemporalitySelector the {@link AggregationTemporalitySelector} to set + * @return this {@link InMemoryMetricReaderBuilder} + */ public InMemoryMetricReaderBuilder setAggregationTemporalitySelector( AggregationTemporalitySelector aggregationTemporalitySelector) { this.aggregationTemporalitySelector = aggregationTemporalitySelector; @@ -33,7 +47,8 @@ public InMemoryMetricReaderBuilder setAggregationTemporalitySelector( } /** - * Sets the {@link DefaultAggregationSelector}. + * Sets the {@link DefaultAggregationSelector} used by {@link + * MetricExporter#getDefaultAggregation(InstrumentType)}. * * @param defaultAggregationSelector the {@link DefaultAggregationSelector} to set * @return this {@link InMemoryMetricReaderBuilder} @@ -56,6 +71,7 @@ public InMemoryMetricReaderBuilder setMemoryMode(MemoryMode memoryMode) { return this; } + /** Constructs a {@link InMemoryMetricReader} based on the builder's values. */ public InMemoryMetricReader build() { return new InMemoryMetricReader( aggregationTemporalitySelector, defaultAggregationSelector, memoryMode); From f747d3c7446e91c0d06e4e6231605cc205d92fa1 Mon Sep 17 00:00:00 2001 From: Jack Berg Date: Tue, 26 Sep 2023 15:04:42 -0500 Subject: [PATCH 2/2] static import --- .../internal/aggregator/LongLastValueAggregatorTest.java | 5 ++--- .../metrics/internal/aggregator/LongSumAggregatorTest.java | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java index 266638dfc46..0ac5104898f 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongLastValueAggregatorTest.java @@ -27,7 +27,6 @@ import io.opentelemetry.sdk.resources.Resource; import java.util.Collections; import java.util.List; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; /** Unit tests for {@link LongLastValueAggregator}. */ @@ -119,7 +118,7 @@ void diffInPlace() { /* Assert that latest measurement is kept and set on {@code previous} */ assertThat(previous.getStartEpochNanos()).isEqualTo(0); assertThat(previous.getEpochNanos()).isEqualTo(1); - Assertions.assertThat(previous.getAttributes()).isEqualTo(Attributes.empty()); + assertThat(previous.getAttributes()).isEqualTo(Attributes.empty()); assertThat(previous.getValue()).isEqualTo(2); assertThat(previous.getExemplars()).isEqualTo(exemplars); } @@ -162,7 +161,7 @@ void copyPoint() { assertThat(toPointData.getStartEpochNanos()).isEqualTo(pointData.getStartEpochNanos()); assertThat(toPointData.getEpochNanos()).isEqualTo(pointData.getEpochNanos()); - Assertions.assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); + assertThat(toPointData.getAttributes()).isEqualTo(pointData.getAttributes()); assertThat(toPointData.getValue()).isEqualTo(pointData.getValue()); assertThat(toPointData.getExemplars()).isEqualTo(pointData.getExemplars()); } diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java index 6cd58796f8f..11b98233b07 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/aggregator/LongSumAggregatorTest.java @@ -273,7 +273,6 @@ void copyPoint() { } @Test - @SuppressWarnings("unchecked") void toMetricData() { AggregatorHandle aggregatorHandle = aggregator.createHandle(); aggregatorHandle.recordLong(10);