YammerMetrics implements Metrics { @VisibleForTesting long getOutstandingRequests() { return gauges.stream().mapToLong(OutstandingRequestsGauge::getOutstandingRequests).sum(); } YammerMetrics(final MetricsRegistry registry); @Override void measureGetFuture(CompletionStage<GetResult<byte[]>> future); @Override void measureMultigetFuture(CompletionStage<List<GetResult<byte[]>>> future); @Override void measureDeleteFuture(CompletionStage<MemcacheStatus> future); @Override void measureSetFuture(CompletionStage<MemcacheStatus> future); @Override void measureIncrDecrFuture(CompletionStage<Long> future); @Override void measureTouchFuture(CompletionStage<MemcacheStatus> future); @Override void registerOutstandingRequestsGauge(OutstandingRequestsGauge gauge); @Override void unregisterOutstandingRequestsGauge(OutstandingRequestsGauge gauge); Timer getGets(); Meter getGetHits(); Meter getGetMisses(); Meter getGetSuccesses(); Meter getGetFailures(); Timer getMultigets(); Meter getMultigetSuccesses(); Meter getMultigetFailures(); Timer getSets(); Meter getSetSuccesses(); Meter getSetFailures(); Timer getDeletes(); Meter getDeleteSuccesses(); Meter getDeleteFailures(); Timer getIncrDecrs(); Meter getIncrDecrSuccesses(); Meter getIncrDecrFailures(); Timer getTouches(); Meter getTouchSuccesses(); Meter getTouchFailures(); static final String GROUP; }
@Test public void testOutstandingRequests() throws Exception { assertEquals(0L, metrics.getOutstandingRequests()); fakeRawMemcacheClient.setOutstandingRequests(5); assertEquals(5L, metrics.getOutstandingRequests()); fakeRawMemcacheClient.setOutstandingRequests(0); assertEquals(0L, metrics.getOutstandingRequests()); }