FDBStoreTimer extends StoreTimer { @Override public void recordTimeout(Wait event, long startTime) { final long totalNanos = System.nanoTime() - startTime; getCounter(Events.TIMEOUTS, true).record(totalNanos); getTimeoutCounter(event, true).record(totalNanos); } FDBStoreTimer(); @Override @Nonnull Set<Aggregate> getAggregates(); @Override void recordTimeout(Wait event, long startTime);  }
@Test public void timeoutCounterDifferenceTest() { RecordCursor<KeyValue> kvc = KeyValueCursor.Builder.withSubspace(subspace).setContext(context).setScanProperties(ScanProperties.FORWARD_SCAN).setRange(TupleRange.ALL).build(); FDBStoreTimer latestTimer = context.getTimer(); CompletableFuture<RecordCursorResult<KeyValue>> fkvr; RecordCursorResult<KeyValue> kvr; latestTimer.recordTimeout(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, System.nanoTime() - 5000); Map<String, Number> diffKVs; diffKVs = latestTimer.getKeysAndValues(); assertEquals(1, diffKVs.get("wait_advance_cursor_timeout_count").intValue()); assertTrue(diffKVs.get("wait_advance_cursor_timeout_micros").intValue() > 0); assertThat(diffKVs.get("wait_advance_cursor_timeout_micros").intValue(), greaterThan(0)); latestTimer.record(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, System.nanoTime()); latestTimer.record(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, System.nanoTime()); StoreTimerSnapshot savedTimer; savedTimer = StoreTimerSnapshot.from(latestTimer); final int numTimeouts = 3; for (int i = 0; i < numTimeouts; i++) { latestTimer.recordTimeout(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, System.nanoTime() - 5000); } diffKVs = latestTimer.getKeysAndValues(); assertEquals(numTimeouts + 1, diffKVs.get("wait_advance_cursor_timeout_count").intValue()); assertThat(diffKVs.get("wait_advance_cursor_timeout_micros").intValue(), greaterThan(0)); StoreTimer diffTimer; diffTimer = StoreTimer.getDifference(latestTimer, savedTimer); diffKVs = diffTimer.getKeysAndValues(); assertEquals(numTimeouts, diffKVs.get("wait_advance_cursor_timeout_count").intValue()); assertThat(diffKVs.get("wait_advance_cursor_timeout_micros").intValue(), greaterThan(0)); }