Kafka batch consume trace broken
xiangtianyu opened this issue · comments
Describe the bug
When i use kafka batch consume, the trace will broken
Steps to reproduce
@RestController
@Slf4j
public class SpringKafkaController {
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@RequestMapping("/kafka/send")
public String sendMessage() {
kafkaTemplate.send("test-topic", "test");
return "success";
}
@KafkaListener(topics = {"test-topic"})
public void listen(List<ConsumerRecord<String, String>> records) {
log.info("receive message");
records.forEach(ConsumerRecord -> {
log.info("topic: {}, partition: {}, offset: {}, key: {}, value: {}", ConsumerRecord.topic(), ConsumerRecord.partition(), ConsumerRecord.offset(), ConsumerRecord.key(), ConsumerRecord.value());
});
}
}
consumer log trace will disappear when i set batch consumer "spring.kafka.listener.type=batch", ps: when the type is single, it's all ok
Expected behavior
show trace normally
Actual behavior
no trace info
Javaagent or library instrumentation version
1.32.0
Environment
JDK: 8
OS: macos
Additional context
No response
@xiangtianyu Please provide a minimal application that reproduces your issue.
https://github.com/xiangtianyu/spring-demo
@xiangtianyu Please provide a minimal application that reproduces your issue.
I didn't try to run the sample app. My guess is that since you are using spring-kafka:2.5.14.RELEASE
which is older than 2.7.0
that is the earliest supported version you get the spans from plain kafka client instrumentation. Spans for the spring kafka listener methods are created by spring-kafka instrumentation so not having a trace in log.info("receive message");
isn't surprising. Kafka client instruments iterating over ConsumerRecords
, here you are using List<ConsumerRecord<String, String>>
so that not working is also expected.
I didn't try to run the sample app. My guess is that since you are using
spring-kafka:2.5.14.RELEASE
which is older than2.7.0
that is the earliest supported version you get the spans from plain kafka client instrumentation. Spans for the spring kafka listener methods are created by spring-kafka instrumentation so not having a trace inlog.info("receive message");
isn't surprising. Kafka client instruments iterating overConsumerRecords
, here you are usingList<ConsumerRecord<String, String>>
so that not working is also expected.
You are right, i tried to use 2.7.0, the trace is all ok. So it means that old version kafka will not support in the future? I must update my kafka version?
So it means that old version kafka will not support in the future?
If a reasonable PR is provided older versions may be supported.
I must update my kafka version?
either update spring kafka version or rework the instrumentation to support older versions
Thanks, i will consider it