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

pl.allegro.tech.hermes.common.metric.ConsumerSenderMetrics 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 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy