Skip to content
Permalink
Browse files

Merge pull request #8 from timtebeek/verify-brave-957

Verify openzipkin/brave#957 through ExtraFieldPropagation.set/get
  • Loading branch information
timtebeek committed Oct 6, 2019
2 parents 73860ce + 4934b28 commit 3ed48a081784730089db03e82f28a34e65a9fa7d
@@ -22,7 +22,11 @@
@Bean
public KStream<String, String> doStream(StreamsBuilder builder) throws Exception {
KStream<String, String> numbersStream = builder.stream("numbers");
numbersStream.transformValues(kafkaStreamsTracing.peek("get", (k, v) -> {
numbersStream.transformValues(kafkaStreamsTracing.peek("set", (k, v) -> {
ExtraFieldPropagation.set(tracer.currentSpan().context(), "messageid", "messageid_" + v);
log.info("set for {} -> {}", k, v);
}))
.transformValues(kafkaStreamsTracing.peek("get", (k, v) -> {
String value = ExtraFieldPropagation.get(tracer.currentSpan().context(), "messageid");
log.info("got: {} for {} -> {}", value, k, v);
log.info("MDC: {}", MDC.getCopyOfContextMap());
@@ -88,7 +88,7 @@ public void verifyExtraFieldPropagation() {
String spanId = RandomStringUtils.randomNumeric(15);
String key = "extra-propagation-" + RandomStringUtils.randomAlphanumeric(10);
ProducerRecord<String, String> producedRecord = record(traceId, spanId, key, 7);
producedRecord.headers().add("messageid", "messageid_7".getBytes());
// producedRecord.headers().add("messageid", "messageid_7".getBytes());
numberProducer.doProduce(producedRecord);

ConsumerRecord<String, String> consumedRecord = oddListener.getOutputFor(cr -> cr.key().equals(key))
@@ -103,7 +103,7 @@ public void verifyExtraFieldPropagation() {

// Assert message_id logged within application
String loglines = new RestTemplate().getForObject("http://localhost:8080/actuator/logfile", String.class);
Assert.assertThat("Expected logfile to contain message_id", loglines, containsString("message_id_7"));
Assert.assertThat("Expected logfile to contain message_id", loglines, containsString("messageid_7"));
}

}

0 comments on commit 3ed48a0

Please sign in to comment.
You can’t perform that action at this time.