@Override
    public void onCycleComplete(com.netflix.hollow.api.producer.Status status, HollowProducer.ReadState readState, long version, Duration elapsed) {
        boolean isCycleSuccess;
        long cycleEndTimeNano = System.nanoTime();

        if (status.getType() == com.netflix.hollow.api.producer.Status.StatusType.SUCCESS) {
            isCycleSuccess = true;
            consecutiveFailures = 0l;
            lastCycleSuccessTimeNanoOptional = OptionalLong.of(cycleEndTimeNano);
        } else {
            isCycleSuccess = false;
            consecutiveFailures ++;
        }

        CycleMetrics.Builder cycleMetricsBuilder = new CycleMetrics.Builder()
                .setConsecutiveFailures(consecutiveFailures)
                .setCycleDurationMillis(elapsed.toMillis())
                .setIsCycleSuccess(isCycleSuccess);
        lastCycleSuccessTimeNanoOptional.ifPresent(cycleMetricsBuilder::setLastCycleSuccessTimeNano);

        cycleMetricsReporting(cycleMetricsBuilder.build());
    }
@Test
    public void testCycleCompleteWithFail() {
        final class TestProducerMetricsListener extends AbstractProducerMetricsListener {
            @Override
            public void cycleMetricsReporting(CycleMetrics cycleMetrics) {
                Assert.assertNotNull(cycleMetrics);
                Assert.assertEquals(1l, cycleMetrics.getConsecutiveFailures());
                Assert.assertEquals(Optional.of(false), cycleMetrics.getIsCycleSuccess());
                Assert.assertEquals(OptionalLong.of(TEST_CYCLE_DURATION_MILLIS.toMillis()), cycleMetrics.getCycleDurationMillis());
                Assert.assertEquals(OptionalLong.of(TEST_LAST_CYCLE_NANOS), cycleMetrics.getLastCycleSuccessTimeNano());
            }
        }

        AbstractProducerMetricsListener concreteProducerMetricsListener = new TestProducerMetricsListener();
        concreteProducerMetricsListener.lastCycleSuccessTimeNanoOptional = OptionalLong.of(TEST_LAST_CYCLE_NANOS);
        concreteProducerMetricsListener.onCycleStart(TEST_VERSION);
        concreteProducerMetricsListener.onCycleComplete(TEST_STATUS_FAIL, mockReadState, TEST_VERSION, TEST_CYCLE_DURATION_MILLIS);
    }