Source:
public synchronized void send(String source, OutgoingMessageEnvelope envelope) { LOG.info(String.format("Trying to send %s", envelope)); if (!isStarted) { throw new SamzaException("Trying to call send before the producer is started."); } String destinationStream = envelope.getSystemStream().getStream(); if (!eventHubClients.containsKey(destinationStream)) { String msg = String.format("Trying to send event to a destination {%s} that is not registered.", destinationStream); throw new SamzaException(msg); } checkCallbackThrowable("Received exception on message send"); EventData eventData = createEventData(destinationStream, envelope); int eventDataLength = eventData.getBytes() == null ? 0 : eventData.getBytes().length; eventWriteRate.get(destinationStream).inc(); aggEventWriteRate.inc(); eventByteWriteRate.get(destinationStream).inc(eventDataLength); aggEventByteWriteRate.inc(eventDataLength); EventHubClientManager ehClient = eventHubClients.get(destinationStream); long beforeSendTimeMs = System.currentTimeMillis(); CompletableFuture<Void> sendResult = sendToEventHub(destinationStream, eventData, getEnvelopePartitionId(envelope), ehClient.getEventHubClient()); long afterSendTimeMs = System.currentTimeMillis(); long latencyMs = afterSendTimeMs - beforeSendTimeMs; sendLatency.get(destinationStream).update(latencyMs); aggSendLatency.update(latencyMs); pendingFutures.add(sendResult); sendResult.handle((aVoid, throwable) -> { long callbackLatencyMs = System.currentTimeMillis() - afterSendTimeMs; sendCallbackLatency.get(destinationStream).update(callbackLatencyMs); aggSendCallbackLatency.update(callbackLatencyMs); if (throwable != null) { sendErrors.get(destinationStream).inc(); aggSendErrors.inc(); LOG.error("Send message to event hub: failed with exception: ", destinationStream, throwable); sendExceptionOnCallback.compareAndSet(null, throwable); } return aVoid; }); }

Target:
public synchronized void send(String source, OutgoingMessageEnvelope envelope) { LOG.debug(String.format("Trying to send %s", envelope)); if (!isStarted) { throw new SamzaException("Trying to call send before the producer is started."); } String streamId = config.getStreamId(envelope.getSystemStream().getStream()); if (!eventHubClients.containsKey(streamId)) { String msg = String.format("Trying to send event to a destination {%s} that is not registered.", streamId); throw new SamzaException(msg); } checkCallbackThrowable("Received exception on message send"); EventData eventData = createEventData(streamId, envelope); int eventDataLength = eventData.getBytes() == null ? 0 : eventData.getBytes().length; eventWriteRate.get(streamId).inc(); aggEventWriteRate.inc(); eventByteWriteRate.get(streamId).inc(eventDataLength); aggEventByteWriteRate.inc(eventDataLength); EventHubClientManager ehClient = eventHubClients.get(streamId); long beforeSendTimeMs = System.currentTimeMillis(); CompletableFuture<Void> sendResult = sendToEventHub(streamId, eventData, getEnvelopePartitionId(envelope), ehClient.getEventHubClient()); long afterSendTimeMs = System.currentTimeMillis(); long latencyMs = afterSendTimeMs - beforeSendTimeMs; sendLatency.get(streamId).update(latencyMs); aggSendLatency.update(latencyMs); pendingFutures.add(sendResult); sendResult.handle((aVoid, throwable) -> { long callbackLatencyMs = System.currentTimeMillis() - afterSendTimeMs; sendCallbackLatency.get(streamId).update(callbackLatencyMs); aggSendCallbackLatency.update(callbackLatencyMs); if (throwable != null) { sendErrors.get(streamId).inc(); aggSendErrors.inc(); LOG.error("Send message to event hub: failed with exception: ", streamId, throwable); sendExceptionOnCallback.compareAndSet(null, throwable); } return aVoid; }); }