pl.allegro.tech.hermes.common.metric.TrackerElasticSearchMetrics 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 pl.allegro.tech.hermes.metrics.HermesTimer;
import java.util.function.ToDoubleFunction;
public class TrackerElasticSearchMetrics {
private final MeterRegistry meterRegistry;
private final GaugeRegistrar gaugeRegistrar;
public TrackerElasticSearchMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
this.gaugeRegistrar = new GaugeRegistrar(meterRegistry);
}
public void registerProducerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
Gauges.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
stateObj, f
);
}
public void registerProducerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
Gauges.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
stateObj, f
);
}
public void registerConsumerTrackerElasticSearchQueueSizeGauge(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
Gauges.TRACKER_ELASTICSEARCH_QUEUE_SIZE,
stateObj, f
);
}
public void registerConsumerTrackerElasticSearchRemainingCapacity(T stateObj, ToDoubleFunction f) {
gaugeRegistrar.registerGauge(
Gauges.TRACKER_ELASTICSEARCH_REMAINING_CAPACITY,
stateObj, f
);
}
public HermesTimer trackerElasticSearchCommitLatencyTimer() {
return HermesTimer.from(
meterRegistry.timer(Timers.ELASTICSEARCH_COMMIT_LATENCY)
);
}
private static class Gauges {
public static final String TRACKER_ELASTICSEARCH_QUEUE_SIZE = "tracker.elasticsearch.queue-size";
public static final String TRACKER_ELASTICSEARCH_REMAINING_CAPACITY = "tracker.elasticsearch.remaining-capacity";
}
private static class Timers {
public static final String ELASTICSEARCH_COMMIT_LATENCY = "tracker.elasticsearch.commit-latency";
}
}