Search in sources :

Example 41 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project resilience4j by resilience4j.

the class RateLimiterMetrics method bindTo.

@Override
public void bindTo(MeterRegistry registry) {
    for (RateLimiter rateLimiter : rateLimiters) {
        final String name = rateLimiter.getName();
        Gauge.builder(getName(prefix, name, AVAILABLE_PERMISSIONS), rateLimiter, (cb) -> cb.getMetrics().getAvailablePermissions()).register(registry);
        Gauge.builder(getName(prefix, name, WAITING_THREADS), rateLimiter, (cb) -> cb.getMetrics().getNumberOfWaitingThreads()).register(registry);
    }
}
Also used : Gauge(io.micrometer.core.instrument.Gauge) MetricUtils.getName(io.github.resilience4j.micrometer.MetricUtils.getName) RateLimiter(io.github.resilience4j.ratelimiter.RateLimiter) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Objects.requireNonNull(java.util.Objects.requireNonNull) MeterBinder(io.micrometer.core.instrument.binder.MeterBinder) WAITING_THREADS(io.github.resilience4j.ratelimiter.utils.MetricNames.WAITING_THREADS) AVAILABLE_PERMISSIONS(io.github.resilience4j.ratelimiter.utils.MetricNames.AVAILABLE_PERMISSIONS) RateLimiterRegistry(io.github.resilience4j.ratelimiter.RateLimiterRegistry) DEFAULT_PREFIX(io.github.resilience4j.ratelimiter.utils.MetricNames.DEFAULT_PREFIX) RateLimiter(io.github.resilience4j.ratelimiter.RateLimiter)

Example 42 with MeterRegistry

use of io.micrometer.core.instrument.MeterRegistry in project resilience4j by resilience4j.

the class RetryMetrics method bindTo.

@Override
public void bindTo(MeterRegistry registry) {
    for (Retry retry : retries) {
        final String name = retry.getName();
        Gauge.builder(getName(prefix, name, SUCCESSFUL_CALLS_WITHOUT_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfSuccessfulCallsWithoutRetryAttempt()).register(registry);
        Gauge.builder(getName(prefix, name, SUCCESSFUL_CALLS_WITH_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfSuccessfulCallsWithRetryAttempt()).register(registry);
        Gauge.builder(getName(prefix, name, FAILED_CALLS_WITHOUT_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfFailedCallsWithoutRetryAttempt()).register(registry);
        Gauge.builder(getName(prefix, name, FAILED_CALLS_WITH_RETRY), retry, (cb) -> cb.getMetrics().getNumberOfFailedCallsWithRetryAttempt()).register(registry);
    }
}
Also used : DEFAULT_PREFIX(io.github.resilience4j.retry.utils.MetricNames.DEFAULT_PREFIX) SUCCESSFUL_CALLS_WITH_RETRY(io.github.resilience4j.retry.utils.MetricNames.SUCCESSFUL_CALLS_WITH_RETRY) Retry(io.github.resilience4j.retry.Retry) Gauge(io.micrometer.core.instrument.Gauge) MetricUtils.getName(io.github.resilience4j.micrometer.MetricUtils.getName) SUCCESSFUL_CALLS_WITHOUT_RETRY(io.github.resilience4j.retry.utils.MetricNames.SUCCESSFUL_CALLS_WITHOUT_RETRY) MeterBinder(io.micrometer.core.instrument.binder.MeterBinder) FAILED_CALLS_WITHOUT_RETRY(io.github.resilience4j.retry.utils.MetricNames.FAILED_CALLS_WITHOUT_RETRY) FAILED_CALLS_WITH_RETRY(io.github.resilience4j.retry.utils.MetricNames.FAILED_CALLS_WITH_RETRY) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Objects.requireNonNull(java.util.Objects.requireNonNull) RetryRegistry(io.github.resilience4j.retry.RetryRegistry) RateLimiterRegistry(io.github.resilience4j.ratelimiter.RateLimiterRegistry) Retry(io.github.resilience4j.retry.Retry)

Aggregations

MeterRegistry (io.micrometer.core.instrument.MeterRegistry)42 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)21 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 Timer (io.micrometer.core.instrument.Timer)9 Duration (java.time.Duration)9 SampleConfig (io.micrometer.core.samples.utils.SampleConfig)8 Match (io.vertx.micrometer.Match)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Normal (cern.jet.random.Normal)6 MersenneTwister64 (cern.jet.random.engine.MersenneTwister64)6 RandomEngine (cern.jet.random.engine.RandomEngine)6 Gauge (io.micrometer.core.instrument.Gauge)6 Flux (reactor.core.publisher.Flux)6 Counter (io.micrometer.core.instrument.Counter)5 MetricUtils.getName (io.github.resilience4j.micrometer.MetricUtils.getName)4 MeterBinder (io.micrometer.core.instrument.binder.MeterBinder)4 PrometheusMeterRegistry (io.micrometer.prometheus.PrometheusMeterRegistry)4 Objects.requireNonNull (java.util.Objects.requireNonNull)4 TimeUnit (java.util.concurrent.TimeUnit)4