@Override
    public void onCycleSkip(CycleSkipReason reason) {
        CycleMetrics.Builder cycleMetricsBuilder = new CycleMetrics.Builder();

        cycleMetricsBuilder.setConsecutiveFailures(consecutiveFailures);
        lastCycleSuccessTimeNanoOptional.ifPresent(cycleMetricsBuilder::setLastCycleSuccessTimeNano);
        // isCycleSuccess and cycleDurationMillis are not set for skipped cycles

        cycleMetricsReporting(cycleMetricsBuilder.build());
    }
@Test
    public void testCycleSkipWhenPreviouslyPrimaryProducer() {
        final class TestProducerMetricsListener extends AbstractProducerMetricsListener {
            @Override
            public void cycleMetricsReporting(CycleMetrics cycleMetrics) {
                Assert.assertNotNull(cycleMetrics);
                Assert.assertEquals(0l, cycleMetrics.getConsecutiveFailures());
                Assert.assertEquals(Optional.empty(), cycleMetrics.getIsCycleSuccess());
                Assert.assertEquals(OptionalLong.empty(), 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.onCycleSkip(CycleListener.CycleSkipReason.NOT_PRIMARY_PRODUCER);
    }