package io.vertx.ext.dropwizard.impl;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.RatioGauge;
import io.vertx.core.net.SocketAddress;
class HttpClientReporter extends HttpMetricsImpl {
int totalMaxPoolSize;
public HttpClientReporter(MetricRegistry registry, String baseName, SocketAddress localAdress) {
super(registry, baseName, localAdress);
gauge(() -> totalMaxPoolSize, "connections", "max-pool-size");
RatioGauge gauge = new RatioGauge() {
@Override
protected Ratio getRatio() {
return Ratio.of(connections(), totalMaxPoolSize);
}
};
gauge(gauge, "connections", "pool-ratio");
}
void incMaxPoolSize(int maxPoolSize) {
totalMaxPoolSize += maxPoolSize;
}
boolean decMaxPoolSize(int maxPoolSize) {
totalMaxPoolSize -= maxPoolSize;
return totalMaxPoolSize == 0;
}
}