- Чего я пытаюсь достичь: < /li>
< /ul>
Я хотел бы отправить трассы в структурированном формате (например, json) при написании, создавая следы в кафке. Проект + Микрометр < /p>
@Bean
public KafkaTemplate kafkaTemplate(ProducerFactory producerFactory) {
KafkaTemplate t = new KafkaTemplate(producerFactory);
t.setObservationEnabled(true);
t.setObservationConvention(new KafkaTemplateObservationConvention() {
@Override
public KeyValues getLowCardinalityKeyValues(KafkaRecordSenderContext context) {
return KeyValues.of("topic", context.getDestination(),
"id", String.valueOf(context.getRecord().key()));
}
});
return t;
}
< /code>
template.send(topic, info.getId(), info);
< /code>
or a reactor kafka project + micrometer
@Bean
public KafkaSender kafkaSender(ObservationRegistry observationRegistry) {
final Map properties = new ConcurrentHashMap();
properties.put(...);
final SenderOptions senderOptions = SenderOptions.create(properties);
return KafkaSender.create(senderOptions.withObservation(observationRegistry));
}
< /code>
kafkaSender.send(...
< /code>
I managed to send traces
Describe actual results
The actual result seems very strange. This is what I can see in the topic:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic quickstart-events --property print.key=true --property print.headers=true
< /code>
traceparent, 00-8B8501B4CF91D41FED3E7348452D7119-89BB34C5CDE2A6D1-01, __typeid__, sometype
< /code>
It seems the header, which contains the trace, is unstructured.
- Question:
Also, side question, how is it possible a spring Kafka consumer, or a reactor Kafka consumer is able to "understand" this unstructured header, to produce something like this:

Подробнее здесь: https://stackoverflow.com/questions/795 ... ring-kafka