All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.common.metric.BrokerMetrics Maven / Gradle / Ivy

There is a newer version: 2.7.0
Show newest version
package pl.allegro.tech.hermes.common.metric;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import pl.allegro.tech.hermes.api.Topic;

import java.time.Duration;

public class BrokerMetrics {
    private final MeterRegistry meterRegistry;

    public BrokerMetrics(MeterRegistry meterRegistry) {
        this.meterRegistry = meterRegistry;
    }

    public void recordBrokerLatency(String broker, Topic.Ack ack, Duration duration) {
        Timer.builder("broker.latency")
                .tag("broker", broker)
                .tag("ack", ack.name())
                .publishPercentileHistogram()
                .maximumExpectedValue(Duration.ofSeconds(5))
                .register(meterRegistry)
                .record(duration);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy