Source:
<code>private void sampleCountsReceived(final SampleCounts sampleCounts) { final Task task = sampleCounts.getTask(); final Optional<Throwable> failure = sampleCounts.getFailure(); final Metrics metrics = _metricsFactory.create(); metrics.addAnnotation("trigger", task.getTrigger().name()); metrics.addAnnotation("period", task.getPeriod().name()); metrics.incrementCounter("rollup/consistency_checker/query_successful", failure.isPresent() ? 0 : 1); if (failure.isPresent()) { LOGGER.warn() .setMessage("failed to query Kairos for sample-counts") .addData("task", task) .setThrowable(failure.get()) .log(); return; <START> } <END> final double nOriginalSamples = sampleCounts.getSourceSampleCount(); final double nSamplesDropped = nOriginalSamples - sampleCounts.getRollupSampleCount(); final double fractionalDataLoss = nSamplesDropped / nOriginalSamples; metrics.setGauge("rollup/consistency_checker/fractional_data_loss", fractionalDataLoss); final LogBuilder logBuilder = fractionalDataLoss == 0 ? LOGGER.trace() : fractionalDataLoss < 0.001 ? LOGGER.debug() : fractionalDataLoss < 0.01 ? LOGGER.info() : fractionalDataLoss < 0.1 ? LOGGER.warn() : LOGGER.error(); logBuilder.setMessage((fractionalDataLoss == 0 ? "no " : "") + "data lost in rollup") .addData("task", task) .addData("nOriginalSamples", nOriginalSamples) .addData("nSamplesDropped", nSamplesDropped) .addData("fractionalDataLoss", fractionalDataLoss) .log(); }</code><technical_language>work pick-up apache sink version 0.11.1: <LINK_1> Specifically, need: <LINK_0></technical_language>

Target:
private void sampleCountsReceived(final SampleCounts sampleCounts) { final Task task = sampleCounts.getTask(); final Optional<Throwable> failure = sampleCounts.getFailure(); try (Metrics metrics = _metricsFactory.create()) { metrics.addAnnotation("trigger", task.getTrigger().name()); metrics.addAnnotation("period", task.getPeriod().name()); metrics.incrementCounter("rollup/consistency_checker/query_successful", failure.isPresent() ? 0 : 1); if (failure.isPresent()) { LOGGER.warn() .setMessage("failed to query Kairos for sample-counts") .addData("task", task) .setThrowable(failure.get()) .log(); return; } final double nOriginalSamples = sampleCounts.getSourceSampleCount(); final double nRollupSamples = sampleCounts.getRollupSampleCount(); final double nSamplesDropped = nOriginalSamples - nRollupSamples; final boolean tooManyRollupSamples = nOriginalSamples < nRollupSamples; recordCounter("too_many_rollup_samples", tooManyRollupSamples ? 1 : 0); if (tooManyRollupSamples) { LOGGER.error() .setMessage("somehow got more samples for rolled-up data than original data") .addData("task", task) .addData("sampleCounts", sampleCounts) .log(); } else if (nOriginalSamples > nRollupSamples) { final double fractionalDataLoss = nSamplesDropped / nOriginalSamples; metrics.setGauge("rollup/consistency_checker/fractional_data_loss", fractionalDataLoss); final LogBuilder logBuilder = fractionalDataLoss < 0.001 ? LOGGER.debug() : fractionalDataLoss < 0.01 ? LOGGER.info() : fractionalDataLoss < 0.1 ? LOGGER.warn() : LOGGER.error(); logBuilder.setMessage("data lost in rollup") .addData("task", task) .addData("sampleCounts", sampleCounts) .log(); } else { LOGGER.trace() .setMessage("no data lost in rollup") .addData("task", task) .addData("sampleCounts", sampleCounts) .log(); } } }