Source:
<code>private void onSendCallback(DatastreamRecordMetadata metadata, Exception exception, SendCallback sendCallback, DatastreamTask task, DatastreamProducerRecord record) { SendFailedException sendFailedException = null; if (exception != null) { sendFailedException = new SendFailedException(_safeCheckpoints); if (_onUnrecoverableError != null) { _onUnrecoverableError.accept(this); } } else { synchronized (_latency) { _latency = System.currentTimeMillis() - record.getEventsTimestamp(); <START> if (_latency <= _availabilityThresholdSlaMs) { <END> EVENTS_PRODUCED_WITHIN_SLA.inc(); } else { _dynamicMetricsManager.createOrUpdateCounter(this.getClass(), metadata.getTopic(), EVENTS_PRODUCED_OUTSIDE_SLA, 1); _logger.warn( String.format("Event latency of %d for source %s, topic %s, partition %d exceeded SLA of %d millseconds", _latency, task.getDatastreamSource().getConnectionString(), metadata.getTopic(), metadata.getPartition(), _availabilityThresholdSlaMs)); } TOTAL_EVENTS_PRODUCED.inc(); } try { _checkpointRWLock.readLock().lock(); if (!_safeCheckpoints.containsKey(task)) { _logger.warn(String.format("Event of unknown task is being acknowledged: task=%s, record=%s", task, record)); } else { _safeCheckpoints.get(task).put(metadata.getPartition(), record.getCheckpoint()); _pendingCheckpoints.set(true); } } finally { _checkpointRWLock.readLock().unlock(); } } if (sendCallback != null) { sendCallback.onCompletion(metadata, sendFailedException); } if (exception != null) { shutdown(); } }</code><technical_language>(Lines this a hint needs fixing: comparing a unitless variable units.)</technical_language>

Target:
private void onSendCallback(DatastreamRecordMetadata metadata, Exception exception, SendCallback sendCallback, DatastreamTask task, DatastreamProducerRecord record) { SendFailedException sendFailedException = null; if (exception != null) { sendFailedException = new SendFailedException(_safeCheckpoints); if (_onUnrecoverableError != null) { _onUnrecoverableError.accept(this); } } else { synchronized (_sourceToDestinationLatencyMs) { _sourceToDestinationLatencyMs = System.currentTimeMillis() - record.getEventsTimestamp(); if (_sourceToDestinationLatencyMs <= _availabilityThresholdSlaMs) { EVENTS_PRODUCED_WITHIN_SLA.inc(); } else { _dynamicMetricsManager.createOrUpdateCounter(this.getClass(), metadata.getTopic(), EVENTS_PRODUCED_OUTSIDE_SLA, 1); _logger.warn( String.format("Event latency of %d for source %s, topic %s, partition %d exceeded SLA of %d millseconds", _sourceToDestinationLatencyMs, task.getDatastreamSource().getConnectionString(), metadata.getTopic(), metadata.getPartition(), _availabilityThresholdSlaMs)); } TOTAL_EVENTS_PRODUCED.inc(); } try { _checkpointRWLock.readLock().lock(); if (!_safeCheckpoints.containsKey(task)) { _logger.warn(String.format("Event of unknown task is being acknowledged: task=%s, record=%s", task, record)); } else { _safeCheckpoints.get(task).put(metadata.getPartition(), record.getCheckpoint()); _pendingCheckpoints.set(true); } } finally { _checkpointRWLock.readLock().unlock(); } } if (sendCallback != null) { sendCallback.onCompletion(metadata, sendFailedException); } if (exception != null) { shutdown(); } }