pl.allegro.tech.hermes.common.metric.ConsumerSenderMetrics 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 java.util.function.ToDoubleFunction;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_ACTIVE_CONNECTIONS;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_IDLE_CONNECTIONS;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_ACTIVE_CONNECTIONS;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_IDLE_CONNECTIONS;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_CONNECTIONS;
import static pl.allegro.tech.hermes.common.metric.Gauges.CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_PENDING_CONNECTIONS;
public class ConsumerSenderMetrics {
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
ConsumerSenderMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
meterRegistry.gauge("http-clients.request-queue-size", obj, f);
}
public void registerHttp1SerialClientRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
meterRegistry.gauge("http-clients.serial.http1.request-queue-size", obj, f);
}
public void registerHttp1BatchClientRequestQueueSizeGauge(T obj, ToDoubleFunction f) {
meterRegistry.gauge("http-clients.batch.http1.request-queue-size", obj, f);
}
public void registerHttp2RequestQueueSizeGauge(T obj, ToDoubleFunction f) {
meterRegistry.gauge("http-clients.serial.http2.request-queue-size", obj, f);
}
public void registerHttp1SerialClientActiveConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_ACTIVE_CONNECTIONS, obj, f);
}
public void registerHttp1SerialClientIdleConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_1_SERIAL_CLIENT_IDLE_CONNECTIONS, obj, f);
}
public void registerHttp1BatchClientActiveConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_ACTIVE_CONNECTIONS, obj, f);
}
public void registerHttp1BatchClientIdleConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_1_BATCH_CLIENT_IDLE_CONNECTIONS, obj, f);
}
public void registerHttp2SerialClientConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_CONNECTIONS, obj, f);
}
public void registerHttp2SerialClientPendingConnectionsGauge(T obj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(CONSUMER_SENDER_HTTP_2_SERIAL_CLIENT_PENDING_CONNECTIONS, obj, f);
}
}