Выпуск отправки следов заголовка с затратамиJAVA

Программисты JAVA общаются здесь
Anonymous
Выпуск отправки следов заголовка с затратами

Сообщение Anonymous »

  • Чего я пытаюсь достичь: < /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
While I can see the trace being sent (in any distributed aggregator system, such as Zipkin)
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:
How to send the header that contains the traceparent, in a structured format (such as JSON)?
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

Вернуться в «JAVA»