Skip to content
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

Cleanup a few typos #5855

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*
* <p>This class is not thread-safe.
*/
public class ArrayBasedStack<T> {
public final class ArrayBasedStack<T> {
// Visible for test
static final int DEFAULT_CAPACITY = 10;

// NOTE (asafm): Using native array instead of ArrayList since I plan to add eviction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* <p>This class is not thread-safe.
*/
public class MutableMeasurement implements Measurement {
public final class MutableMeasurement implements Measurement {

static void setDoubleMeasurement(
MutableMeasurement mutableMeasurement,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* <p>This class is not thread-safe.
*/
public class ObjectPool<T> {
public final class ObjectPool<T> {
private final ArrayBasedStack<T> pool;
private final Supplier<T> objectCreator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @param <V> The map value type
*/
@SuppressWarnings("ForLoopReplaceableByForEach")
public class PooledHashMap<K, V> implements Map<K, V> {
public final class PooledHashMap<K, V> implements Map<K, V> {
private static final int DEFAULT_CAPACITY = 16;
private static final float LOAD_FACTOR = 0.75f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}. */
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,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;

/** Unit tests for {@link LongLastValueAggregator}. */
Expand Down Expand Up @@ -120,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);
OpenTelemetryAssertions.assertThat(previous.getAttributes()).isEqualTo(Attributes.empty());
assertThat(previous.getAttributes()).isEqualTo(Attributes.empty());
assertThat(previous.getValue()).isEqualTo(2);
assertThat(previous.getExemplars()).isEqualTo(exemplars);
}
Expand Down Expand Up @@ -161,13 +159,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -266,17 +265,14 @@ 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
@SuppressWarnings("unchecked")
void toMetricData() {
AggregatorHandle<LongPointData, LongExemplarData> aggregatorHandle = aggregator.createHandle();
aggregatorHandle.recordLong(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Integer> 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<String, Integer> actualMap = new HashMap<>();
map.forEach(actualMap::put);

Assertions.assertThat(actualMap).containsOnlyKeys("One", "Two").containsValues(1, 2);
assertThat(actualMap).containsOnlyKeys("One", "Two").containsValues(1, 2);
}
}
13 changes: 0 additions & 13 deletions sdk/metrics/testing-internal/build.gradle.kts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading