diff --git a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java index 9ce7682b279..2d301eb6d88 100644 --- a/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java +++ b/sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/internal/state/SynchronousMetricStorageTest.java @@ -47,7 +47,6 @@ import java.util.concurrent.CountDownLatch; import java.util.function.BiConsumer; import java.util.stream.Stream; -import org.junit.jupiter.api.RepeatedTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; @@ -459,61 +458,4 @@ private static Stream concurrentStressTestArguments() { (BiConsumer) (value, cumulativeCount) -> cumulativeCount.set(value))); } - - @RepeatedTest(100) - void recordAndCollect_concurrentStressTestRepeated() { - DefaultSynchronousMetricStorage storage = - new DefaultSynchronousMetricStorage<>( - RegisteredReader.create(InMemoryMetricReader.createDelta(), ViewRegistry.create()), - METRIC_DESCRIPTOR, - aggregator, - AttributesProcessor.noop(), - CARDINALITY_LIMIT); - BiConsumer collect = - (BiConsumer) - (value, cumulativeCount) -> cumulativeCount.addAndGet(value); - - // Define record threads. Each records a value of 1.0, 2000 times - List threads = new ArrayList<>(); - CountDownLatch latch = new CountDownLatch(4); - for (int i = 0; i < 4; i++) { - Thread thread = - new Thread( - () -> { - for (int j = 0; j < 2000; j++) { - storage.recordDouble(1.0, Attributes.empty(), Context.current()); - Uninterruptibles.sleepUninterruptibly(Duration.ofMillis(1)); - } - latch.countDown(); - }); - threads.add(thread); - } - - // Define collect thread. Collect thread collects and aggregates the - AtomicDouble cumulativeSum = new AtomicDouble(); - Thread collectThread = - new Thread( - () -> { - do { - Uninterruptibles.sleepUninterruptibly(Duration.ofMillis(1)); - MetricData metricData = - storage.collect(Resource.empty(), InstrumentationScopeInfo.empty(), 0, 1); - if (metricData.isEmpty()) { - continue; - } - metricData.getDoubleSumData().getPoints().stream() - .findFirst() - .ifPresent(pointData -> collect.accept(pointData.getValue(), cumulativeSum)); - } while (latch.getCount() != 0); - }); - - // Start all the threads - collectThread.start(); - threads.forEach(Thread::start); - - // Wait for the collect thread to end, which collects until the record threads are done - Uninterruptibles.joinUninterruptibly(collectThread); - - assertThat(cumulativeSum.get()).isEqualTo(8000.0); - } }