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());
}
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());
}
Aggregations