use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TimeLimiterRegistryFactory method timeLimiterRegistry.
@Singleton
@Requires(beans = TimeLimiterConfigurationProperties.class)
public TimeLimiterRegistry timeLimiterRegistry(TimeLimiterConfigurationProperties timeLimiterConfigurationProperties, @TimeLimiterQualifier EventConsumerRegistry<TimeLimiterEvent> timeLimiterEventConsumerRegistry, @TimeLimiterQualifier RegistryEventConsumer<TimeLimiter> timeLimiterRegistryEventConsumer, @TimeLimiterQualifier CompositeCustomizer<TimeLimiterConfigCustomizer> compositeTimeLimiterCustomizer) {
TimeLimiterRegistry timeLimiterRegistry = createTimeLimiterRegistry(timeLimiterConfigurationProperties, timeLimiterRegistryEventConsumer, compositeTimeLimiterCustomizer);
registerEventConsumer(timeLimiterRegistry, timeLimiterEventConsumerRegistry, timeLimiterConfigurationProperties);
initTimeLimiterRegistry(timeLimiterRegistry, timeLimiterConfigurationProperties, compositeTimeLimiterCustomizer);
return timeLimiterRegistry;
}
use of io.github.resilience4j.timelimiter.TimeLimiterRegistry in project resilience4j by resilience4j.
the class TimeLimiterMetricsPublisherTest method customMetricNamesOverrideDefaultOnes.
@Test
public void customMetricNamesOverrideDefaultOnes() {
TimeLimiterMetricsPublisher.MetricNames names = TimeLimiterMetricsPublisher.MetricNames.custom().callsMetricName("custom_calls").build();
CollectorRegistry customRegistry = new CollectorRegistry();
TimeLimiterMetricsPublisher timeLimiterMetricsPublisher = new TimeLimiterMetricsPublisher(names);
timeLimiterMetricsPublisher.register(customRegistry);
TimeLimiterRegistry timeLimiterRegistry = TimeLimiterRegistry.of(TimeLimiterConfig.ofDefaults(), timeLimiterMetricsPublisher);
TimeLimiter timeLimiter = timeLimiterRegistry.timeLimiter("backendA");
timeLimiter.onSuccess();
timeLimiter.onError(new RuntimeException());
timeLimiter.onError(new TimeoutException());
Double successfulCalls = getSampleValue(customRegistry, "custom_calls", KIND_SUCCESSFUL);
Double failedCalls = getSampleValue(customRegistry, "custom_calls", KIND_FAILED);
Double timeoutCalls = getSampleValue(customRegistry, "custom_calls", KIND_TIMEOUT);
assertThat(successfulCalls).isNotNull();
assertThat(failedCalls).isNotNull();
assertThat(timeoutCalls).isNotNull();
}
Aggregations