Source:
<code>public void sendStartSpanSingleMessage() { final Tracer tracer1 = mock(Tracer.class); <START> List<Tracer> tracers = new ArrayList<>(Arrays.asList(tracer1)); <END> TracerProvider tracerProvider = new TracerProvider(tracers); final Flux<EventData> testData = Flux.just( new EventData(TEST_CONTENTS.getBytes(UTF_8)), new EventData(TEST_CONTENTS.getBytes(UTF_8))); when(sendLink.send(anyList())).thenReturn(Mono.empty()); final SendOptions options = new SendOptions().partitionKey("Some partition key"); final EventHubProducerOptions producerOptions = new EventHubProducerOptions() .retry(new RetryOptions().tryTimeout(Duration.ofSeconds(30))) .partitionId("my-partition-id"); final EventHubAsyncProducer producer = new EventHubAsyncProducer(Mono.just(sendLink), producerOptions, tracerProvider); when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); } ); when(tracer1.start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); return passed.addData(OPENTELEMETRY_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); } ); producer.send(testData).block(Duration.ofSeconds(10)); verify(tracer1, times(2)).start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND)); verify(tracer1, times(2)).start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE)); verify(tracer1, times(3)).end(eq("success"), isNull(), any()); }</code><technical_language>List<Tracer> tracers = Arrays.asList(tracer1);</technical_language>

Target:
public void sendStartSpanSingleMessage() { final Tracer tracer1 = mock(Tracer.class); final List<Tracer> tracers = Collections.singletonList(tracer1); TracerProvider tracerProvider = new TracerProvider(tracers); final Flux<EventData> testData = Flux.just( new EventData(TEST_CONTENTS.getBytes(UTF_8)), new EventData(TEST_CONTENTS.getBytes(UTF_8))); when(sendLink.send(anyList())).thenReturn(Mono.empty()); final EventHubProducerOptions producerOptions = new EventHubProducerOptions() .retry(new RetryOptions().tryTimeout(Duration.ofSeconds(30))) .partitionId("my-partition-id"); final EventHubAsyncProducer producer = new EventHubAsyncProducer(Mono.just(sendLink), producerOptions, tracerProvider); when(tracer1.start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); return passed.addData(OPENTELEMETRY_SPAN_KEY, "value"); } ); when(tracer1.start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE))).thenAnswer( invocation -> { Context passed = invocation.getArgument(1, Context.class); return passed.addData(OPENTELEMETRY_SPAN_KEY, "value").addData(DIAGNOSTIC_ID_KEY, "value2"); } ); StepVerifier.create(producer.send(testData)).verifyComplete(); verify(tracer1, times(2)).start(eq("Azure.eventhubs.send"), any(), eq(ProcessKind.SEND)); verify(tracer1, times(2)).start(eq("Azure.eventhubs.message"), any(), eq(ProcessKind.RECEIVE)); verify(tracer1, times(3)).end(eq("success"), isNull(), any()); }