Search in sources :

Example 1 with TAG_ON_COMPLETE_EMPTY

use of reactor.core.publisher.FluxMetrics.TAG_ON_COMPLETE_EMPTY in project reactor-core by reactor.

the class FluxMetricsFuseableTest method completeEmptyAsyncFusion.

@Test
public void completeEmptyAsyncFusion() {
    Flux<Integer> source = Flux.range(1, 10).filter(i -> i > 100).onBackpressureBuffer();
    StepVerifier.create(new FluxMetricsFuseable<>(source)).expectFusion(Fuseable.ASYNC).verifyComplete();
    Timer stcCompleteCounter = registry.find(REACTOR_DEFAULT_NAME + METER_FLOW_DURATION).tags(Tags.of(TAG_ON_COMPLETE)).timer();
    Timer stcCompleteEmptyCounter = registry.find(REACTOR_DEFAULT_NAME + METER_FLOW_DURATION).tags(Tags.of(TAG_ON_COMPLETE_EMPTY)).timer();
    assertThat(stcCompleteCounter).as("complete with element").isNull();
    assertThat(stcCompleteEmptyCounter).as("complete without any element").isNotNull().satisfies(timer -> assertThat(timer.count()).as("timer count").isOne());
}
Also used : Metrics(reactor.util.Metrics) BeforeEach(org.junit.jupiter.api.BeforeEach) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SoftAssertions(org.assertj.core.api.SoftAssertions) StepVerifier(reactor.test.StepVerifier) MockClock(io.micrometer.core.instrument.MockClock) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AtomicReference(java.util.concurrent.atomic.AtomicReference) Timer(io.micrometer.core.instrument.Timer) Duration(java.time.Duration) Counter(io.micrometer.core.instrument.Counter) Tags(io.micrometer.core.instrument.Tags) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Clock(io.micrometer.core.instrument.Clock) SimpleConfig(io.micrometer.core.instrument.simple.SimpleConfig) TAG_ON_COMPLETE_EMPTY(reactor.core.publisher.FluxMetrics.TAG_ON_COMPLETE_EMPTY) FluxMetrics(reactor.core.publisher.FluxMetrics) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) AfterEach(org.junit.jupiter.api.AfterEach) Fuseable(reactor.core.Fuseable) DistributionSummary(io.micrometer.core.instrument.DistributionSummary) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Subscription(org.reactivestreams.Subscription) AssertSubscriber(reactor.test.subscriber.AssertSubscriber) Assertions.assertThatCode(org.assertj.core.api.Assertions.assertThatCode) Timer(io.micrometer.core.instrument.Timer) Test(org.junit.jupiter.api.Test)

Aggregations

Clock (io.micrometer.core.instrument.Clock)1 Counter (io.micrometer.core.instrument.Counter)1 DistributionSummary (io.micrometer.core.instrument.DistributionSummary)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 MockClock (io.micrometer.core.instrument.MockClock)1 Tags (io.micrometer.core.instrument.Tags)1 Timer (io.micrometer.core.instrument.Timer)1 SimpleConfig (io.micrometer.core.instrument.simple.SimpleConfig)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 Duration (java.time.Duration)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatCode (org.assertj.core.api.Assertions.assertThatCode)1 Assertions.assertThatIllegalStateException (org.assertj.core.api.Assertions.assertThatIllegalStateException)1 SoftAssertions (org.assertj.core.api.SoftAssertions)1 AfterEach (org.junit.jupiter.api.AfterEach)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 Subscription (org.reactivestreams.Subscription)1