use of io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry in project resilience4j by resilience4j.
the class ThreadPoolBulkheadFactory method threadPoolBulkheadRegistry.
@Singleton
@Requires(beans = ThreadPoolBulkheadConfigurationProperties.class)
public ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry(ThreadPoolBulkheadConfigurationProperties bulkheadConfigurationProperties, @ThreadPoolBulkheadQualifier EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, @ThreadPoolBulkheadQualifier RegistryEventConsumer<ThreadPoolBulkhead> threadPoolBulkheadRegistryEventConsumer, @ThreadPoolBulkheadQualifier CompositeCustomizer<ThreadPoolBulkheadConfigCustomizer> compositeThreadPoolBulkheadCustomizer) {
ThreadPoolBulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, threadPoolBulkheadRegistryEventConsumer, compositeThreadPoolBulkheadCustomizer);
registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties);
bulkheadConfigurationProperties.getBackends().forEach((name, properties) -> bulkheadRegistry.bulkhead(name, bulkheadConfigurationProperties.createThreadPoolBulkheadConfig(name, compositeThreadPoolBulkheadCustomizer)));
return bulkheadRegistry;
}
use of io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry in project resilience4j by resilience4j.
the class ThreadPoolBulkheadConfiguration method threadPoolBulkheadRegistry.
/**
* @param bulkheadConfigurationProperties bulk head spring configuration properties
* @param bulkheadEventConsumerRegistry the bulk head event consumer registry
* @return the ThreadPoolBulkheadRegistry with all needed setup in place
*/
@Bean
public ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry(ThreadPoolBulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<ThreadPoolBulkhead> threadPoolBulkheadRegistryEventConsumer, @Qualifier("compositeThreadPoolBulkheadCustomizer") CompositeCustomizer<ThreadPoolBulkheadConfigCustomizer> compositeThreadPoolBulkheadCustomizer) {
ThreadPoolBulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, threadPoolBulkheadRegistryEventConsumer, compositeThreadPoolBulkheadCustomizer);
registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties);
bulkheadConfigurationProperties.getBackends().forEach((name, properties) -> bulkheadRegistry.bulkhead(name, bulkheadConfigurationProperties.createThreadPoolBulkheadConfig(name, compositeThreadPoolBulkheadCustomizer)));
return bulkheadRegistry;
}
use of io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry in project resilience4j by resilience4j.
the class TaggedThreadPoolBulkheadMetricsPublisherTest method customMetricNamesGetApplied.
@Test
public void customMetricNamesGetApplied() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
TaggedThreadPoolBulkheadMetricsPublisher taggedBulkheadMetricsPublisher = new TaggedThreadPoolBulkheadMetricsPublisher(ThreadPoolBulkheadMetricNames.custom().maxThreadPoolSizeMetricName("custom.max.thread.pool.size").coreThreadPoolSizeMetricName("custom.core.thread.pool.size").build(), meterRegistry);
ThreadPoolBulkheadRegistry bulkheadRegistry = ThreadPoolBulkheadRegistry.of(ThreadPoolBulkheadConfig.ofDefaults(), taggedBulkheadMetricsPublisher);
bulkhead = bulkheadRegistry.bulkhead("backendA");
Set<String> metricNames = meterRegistry.getMeters().stream().map(Meter::getId).map(Meter.Id::getName).collect(Collectors.toSet());
assertThat(metricNames).hasSameElementsAs(EXPECTED_METERS);
}
use of io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry in project resilience4j by resilience4j.
the class TaggedThreadPoolBulkheadMetricsTest method customMetricNamesGetApplied.
@Test
public void customMetricNamesGetApplied() {
MeterRegistry meterRegistry = new SimpleMeterRegistry();
ThreadPoolBulkheadRegistry bulkheadRegistry = ThreadPoolBulkheadRegistry.ofDefaults();
bulkhead = bulkheadRegistry.bulkhead("backendA");
TaggedThreadPoolBulkheadMetrics.ofThreadPoolBulkheadRegistry(ThreadPoolBulkheadMetricNames.custom().maxThreadPoolSizeMetricName("custom.max.thread.pool.size").coreThreadPoolSizeMetricName("custom.core.thread.pool.size").build(), bulkheadRegistry).bindTo(meterRegistry);
Set<String> metricNames = meterRegistry.getMeters().stream().map(Meter::getId).map(Meter.Id::getName).collect(Collectors.toSet());
assertThat(metricNames).hasSameElementsAs(EXPECTED_METERS);
}
Aggregations