Search in sources :

Example 16 with ThreadPoolBulkhead

use of io.github.resilience4j.bulkhead.ThreadPoolBulkhead in project resilience4j by resilience4j.

the class TaggedThreadPoolBulkheadMetricsTest method shouldAddMetricsForANewlyCreatedRetry.

@Test
public void shouldAddMetricsForANewlyCreatedRetry() {
    ThreadPoolBulkhead newBulkhead = bulkheadRegistry.bulkhead("backendB");
    assertThat(taggedBulkheadMetrics.meterIdMap).containsKeys("backendA", "backendB");
    assertThat(taggedBulkheadMetrics.meterIdMap.get("backendA")).hasSize(EXPECTED_METER_COUNT);
    assertThat(taggedBulkheadMetrics.meterIdMap.get("backendB")).hasSize(EXPECTED_METER_COUNT);
    List<Meter> meters = meterRegistry.getMeters();
    assertThat(meters).hasSize(EXPECTED_METER_COUNT * 2);
    Collection<Gauge> gauges = meterRegistry.get(DEFAULT_MAX_THREAD_POOL_SIZE_METRIC_NAME).gauges();
    Optional<Gauge> successful = findMeterByNamesTag(gauges, newBulkhead.getName());
    assertThat(successful).isPresent();
    assertThat(successful.get().value()).isEqualTo(newBulkhead.getMetrics().getMaximumThreadPoolSize());
}
Also used : ThreadPoolBulkhead(io.github.resilience4j.bulkhead.ThreadPoolBulkhead) Meter(io.micrometer.core.instrument.Meter) Gauge(io.micrometer.core.instrument.Gauge) Test(org.junit.Test)

Example 17 with ThreadPoolBulkhead

use of io.github.resilience4j.bulkhead.ThreadPoolBulkhead in project resilience4j by resilience4j.

the class TaggedThreadPoolBulkheadMetricsTest method shouldReplaceMetrics.

@Test
public void shouldReplaceMetrics() {
    Collection<Gauge> gauges = meterRegistry.get(DEFAULT_MAX_THREAD_POOL_SIZE_METRIC_NAME).gauges();
    Optional<Gauge> successful = findMeterByNamesTag(gauges, bulkhead.getName());
    assertThat(successful).isPresent();
    assertThat(successful.get().value()).isEqualTo(bulkhead.getMetrics().getMaximumThreadPoolSize());
    ThreadPoolBulkhead newBulkhead = ThreadPoolBulkhead.of(bulkhead.getName(), ThreadPoolBulkheadConfig.custom().maxThreadPoolSize(ThreadPoolBulkheadConfig.DEFAULT_MAX_THREAD_POOL_SIZE + 1).build());
    bulkheadRegistry.replace(bulkhead.getName(), newBulkhead);
    gauges = meterRegistry.get(DEFAULT_MAX_THREAD_POOL_SIZE_METRIC_NAME).gauges();
    successful = findMeterByNamesTag(gauges, newBulkhead.getName());
    assertThat(successful).isPresent();
    assertThat(successful.get().value()).isEqualTo(newBulkhead.getMetrics().getMaximumThreadPoolSize());
}
Also used : ThreadPoolBulkhead(io.github.resilience4j.bulkhead.ThreadPoolBulkhead) Gauge(io.micrometer.core.instrument.Gauge) Test(org.junit.Test)

Aggregations

ThreadPoolBulkhead (io.github.resilience4j.bulkhead.ThreadPoolBulkhead)17 Test (org.junit.Test)15 CircuitBreaker (io.github.resilience4j.circuitbreaker.CircuitBreaker)8 TimeLimiter (io.github.resilience4j.timelimiter.TimeLimiter)8 ContextAwareScheduledThreadPoolExecutor (io.github.resilience4j.core.ContextAwareScheduledThreadPoolExecutor)7 TestThreadLocalContextPropagatorWithHolder (io.github.resilience4j.test.TestContextPropagators.TestThreadLocalContextPropagatorWithHolder)6 Awaitility.matches (com.jayway.awaitility.Awaitility.matches)5 Awaitility.waitAtMost (com.jayway.awaitility.Awaitility.waitAtMost)5 Bulkhead (io.github.resilience4j.bulkhead.Bulkhead)5 BulkheadFullException (io.github.resilience4j.bulkhead.BulkheadFullException)5 Cache (io.github.resilience4j.cache.Cache)5 CallNotPermittedException (io.github.resilience4j.circuitbreaker.CallNotPermittedException)5 CheckedFunction (io.github.resilience4j.core.functions.CheckedFunction)5 CheckedRunnable (io.github.resilience4j.core.functions.CheckedRunnable)5 CheckedSupplier (io.github.resilience4j.core.functions.CheckedSupplier)5 RateLimiter (io.github.resilience4j.ratelimiter.RateLimiter)5 RateLimiterConfig (io.github.resilience4j.ratelimiter.RateLimiterConfig)5 RequestNotPermitted (io.github.resilience4j.ratelimiter.RequestNotPermitted)5 Retry (io.github.resilience4j.retry.Retry)5 AsyncHelloWorldService (io.github.resilience4j.test.AsyncHelloWorldService)5