pl.allegro.tech.hermes.common.metric.BrokerMetrics Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-common Show documentation
Show all versions of hermes-common Show documentation
Fast and reliable message broker built on top of Kafka.
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);
}
}