String serviceName = serviceFactory.getServiceName();
_metrics = Metrics.forInstance(this, serviceName);
_loadTimer = _metrics.newTimer(serviceName, "load-time", TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
_metrics.newGauge(serviceName, "cache-hit-ratio", new RatioGauge() {
@Override protected double getNumerator() { return _requestCount.get() - _missCount.get(); }
@Override protected double getDenominator() { return _requestCount.get(); }
});
_metrics.newGauge(serviceName, "cache-miss-ratio", new RatioGauge() {
@Override protected double getNumerator() { return _missCount.get(); }
@Override protected double getDenominator() { return _requestCount.get(); }
});
_metrics.newGauge(serviceName, "load-success-ratio", new RatioGauge() {
@Override protected double getNumerator() { return _loadSuccessCount.get(); }
@Override protected double getDenominator() {
return _loadSuccessCount.get() + _loadFailureCount.get();
}
});
_metrics.newGauge(serviceName, "load-failure-ratio", new RatioGauge() {
@Override protected double getNumerator() { return _loadFailureCount.get(); }
@Override protected double getDenominator() {
return _loadSuccessCount.get() + _loadFailureCount.get();
}
});