Source:
public Mono<Void> send(EventDataBatch batch) { if (batch == null) { return monoError(logger, new NullPointerException("'batch' cannot be null.")); } else if (batch.getEvents().isEmpty()) { logger.warning("Cannot send an EventBatch that is empty."); return Mono.empty(); } if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())) { logger.info("Sending batch with size[{}] to partitionId[{}].", batch.getSize(), batch.getPartitionId()); } else if (!CoreUtils.isNullOrEmpty(batch.getPartitionKey())) { logger.info("Sending batch with size[{}] with partitionKey[{}].", batch.getSize(), batch.getPartitionKey()); } else { logger.info("Sending batch with size[{}] to be distributed round-robin in service.", batch.getSize()); } final String partitionKey = batch.getPartitionKey(); final boolean isTracingEnabled = tracerProvider.isEnabled(); final AtomicReference<Context> parentContext = isTracingEnabled ? new AtomicReference<>(Context.NONE) : null; final List<Message> messages = batch.getEvents().stream().map(event -> { final Message message = messageSerializer.serialize(event); if (isTracingEnabled) { parentContext.set(event.getContext()); } if (!CoreUtils.isNullOrEmpty(partitionKey)) { final MessageAnnotations messageAnnotations = message.getMessageAnnotations() == null ? new MessageAnnotations(new HashMap<>()) : message.getMessageAnnotations(); messageAnnotations.getValue().put(AmqpConstants.PARTITION_KEY, partitionKey); message.setMessageAnnotations(messageAnnotations); } return message; }).collect(Collectors.toList()); return getSendLink(batch.getPartitionId()) .flatMap(link -> { Context userSpanContext = parentContext.get(); parentContext.set(traceSendSpan(userSpanContext, link)); return messages.size() == 1 ? link.send(messages.get(0)) : link.send(messages); }).doOnEach(signal -> { if (isTracingEnabled) { tracerProvider.endSpan(parentContext.get(), signal); } }); }

Target:
public Mono<Void> send(EventDataBatch batch) { if (batch == null) { return monoError(logger, new NullPointerException("'batch' cannot be null.")); } else if (batch.getEvents().isEmpty()) { logger.warning("Cannot send an EventBatch that is empty."); return Mono.empty(); } if (!CoreUtils.isNullOrEmpty(batch.getPartitionId())) { logger.info("Sending batch with size[{}] to partitionId[{}].", batch.getCount(), batch.getPartitionId()); } else if (!CoreUtils.isNullOrEmpty(batch.getPartitionKey())) { logger.info("Sending batch with size[{}] with partitionKey[{}].", batch.getCount(), batch.getPartitionKey()); } else { logger.info("Sending batch with size[{}] to be distributed round-robin in service.", batch.getCount()); } final String partitionKey = batch.getPartitionKey(); final boolean isTracingEnabled = tracerProvider.isEnabled(); final AtomicReference<Context> parentContext = isTracingEnabled ? new AtomicReference<>(Context.NONE) : null; final List<Message> messages = batch.getEvents().stream().map(event -> { final Message message = messageSerializer.serialize(event); if (isTracingEnabled) { parentContext.set(event.getContext()); } if (!CoreUtils.isNullOrEmpty(partitionKey)) { final MessageAnnotations messageAnnotations = message.getMessageAnnotations() == null ? new MessageAnnotations(new HashMap<>()) : message.getMessageAnnotations(); messageAnnotations.getValue().put(AmqpConstants.PARTITION_KEY, partitionKey); message.setMessageAnnotations(messageAnnotations); } return message; }).collect(Collectors.toList()); return getSendLink(batch.getPartitionId()) .flatMap(link -> { if (isTracingEnabled) { Context userSpanContext = parentContext.get(); Context entityContext = userSpanContext.addData(ENTITY_PATH_KEY, link.getEntityPath()); parentContext.set(tracerProvider.startSpan( entityContext.addData(HOST_NAME_KEY, link.getHostname()), ProcessKind.SEND)); } return messages.size() == 1 ? link.send(messages.get(0)) : link.send(messages); }).doOnEach(signal -> { if (isTracingEnabled) { tracerProvider.endSpan(parentContext.get(), signal); } }); }