Source:
<code>private void receiveEvents(PartitionOwnership partitionOwnership) { EventHubConsumerOptions consumerOptions = new EventHubConsumerOptions(); consumerOptions.ownerLevel(0L); EventPosition startFromEventPosition = partitionOwnership.sequenceNumber() == null ? this.initialEventPosition : EventPosition.fromSequenceNumber(partitionOwnership.sequenceNumber(), false); EventHubAsyncConsumer consumer = this.eventHubAsyncClient .createConsumer(this.consumerGroupName, partitionOwnership.partitionId(), startFromEventPosition, consumerOptions); this.partitionConsumers.put(partitionOwnership.partitionId(), consumer); PartitionContext partitionContext = new PartitionContext(partitionOwnership.partitionId(), this.eventHubName, this.consumerGroupName); CheckpointManager checkpointManager = new CheckpointManager(this.identifier, partitionContext, this.partitionManager, null); logger.info("Subscribing to receive events from partition {}", partitionOwnership.partitionId()); PartitionProcessor partitionProcessor = this.partitionProcessorFactory .createPartitionProcessor(partitionContext, checkpointManager); partitionProcessor.initialize().subscribe(); final AtomicReference<Context> processSpanContext = new AtomicReference<>(Context.NONE); consumer.receive().subscribeOn(Schedulers.newElastic("PartitionPump")) .subscribe(eventData -> { startScopedTracingSpan(eventData, processSpanContext); <START> partitionProcessor.processEvent(eventData).subscribe(unused -> { <END> }, partitionProcessor::processError); endScopedTracingSpan(processSpanContext); }, partitionProcessor::processError, () -> partitionProcessor.close(CloseReason.LOST_PARTITION_OWNERSHIP)); }</code><technical_language>I recall this is asyn call partitionProcessor.processEvent, right? If so, endScopedTracingSpan(processSpanContext) user code returns? I missing something</technical_language>

Target:
private void receiveEvents(PartitionOwnership partitionOwnership) { EventHubConsumerOptions consumerOptions = new EventHubConsumerOptions(); consumerOptions.ownerLevel(0L); EventPosition startFromEventPosition = partitionOwnership.sequenceNumber() == null ? this.initialEventPosition : EventPosition.fromSequenceNumber(partitionOwnership.sequenceNumber(), false); EventHubAsyncConsumer consumer = this.eventHubAsyncClient .createConsumer(this.consumerGroupName, partitionOwnership.partitionId(), startFromEventPosition, consumerOptions); this.partitionConsumers.put(partitionOwnership.partitionId(), consumer); PartitionContext partitionContext = new PartitionContext(partitionOwnership.partitionId(), this.eventHubName, this.consumerGroupName); CheckpointManager checkpointManager = new CheckpointManager(this.identifier, partitionContext, this.partitionManager, null); logger.info("Subscribing to receive events from partition {}", partitionOwnership.partitionId()); PartitionProcessor partitionProcessor = this.partitionProcessorFactory .createPartitionProcessor(partitionContext, checkpointManager); partitionProcessor.initialize().subscribe(); consumer.receive().subscribeOn(Schedulers.newElastic("PartitionPump")) .subscribe(eventData -> { Context processSpanContext = startProcessTracingSpan(eventData); if (processSpanContext.getData(SPAN_CONTEXT).isPresent()) { eventData.addContext(SPAN_CONTEXT, processSpanContext); } partitionProcessor.processEvent(eventData).doOnEach(signal -> endProcessTracingSpan(processSpanContext, signal)).subscribe(unused -> { }, partitionProcessor::processError); }, partitionProcessor::processError, () -> partitionProcessor.close(CloseReason.LOST_PARTITION_OWNERSHIP)); }