adriancole commented on a change in pull request #926: add unit test for 
brave-instrumentation-kafka-clients
URL: 
https://github.com/apache/incubator-zipkin-brave/pull/926#discussion_r294047134
 
 

 ##########
 File path: 
instrumentation/kafka-clients/src/test/java/brave/kafka/clients/ITKafkaTracing.java
 ##########
 @@ -114,6 +114,40 @@ public void close() {
     if (current != null) current.close();
   }
 
+  @Test
+  public void report_producer_spans_to_queue() throws Exception {
+    String topic1 = testName.getMethodName() + "1";
+
+    producer = createTracingProducer();
+    consumer = kafkaRule.helper().createStringConsumer(); // not traced
+
+    for (int i = 0; i < 2; i++) {
+      producer.send(new ProducerRecord<>(topic1, TEST_KEY, TEST_VALUE)).get();
+    }
+    consumer.subscribe(Collections.singletonList(topic1));
+    ConsumerRecords<String, String> records = consumer.poll(10000);
+    assertThat(producerSpans).hasSize(2);
+    assertThat(records).hasSize(2);
 
 Review comment:
   here is ok, just you have a race condition. producerSpans is a blocking 
queue. You can use take() to block until the span is around.
   
   ```java
       ConsumerRecords<String, String> records = consumer.poll(10000);
       assertThat(records).hasSize(2);
   
       producerSpans.take();
       producerSpans.take();
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to