-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for @KafkaListener annotations #1001
Comments
I don't recall supporting |
So, I have to implement my own consumer using Brave, that´s right? |
The easiest approach is to use Spring Cloud Stream https://cloud.spring.io/spring-cloud-stream/ @SpringBootApplication
@EnableBinding(Sink.class)
public class LoggingConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(LoggingConsumerApplication.class, args);
}
@StreamListener(Sink.INPUT)
public void handle(Person person) {
System.out.println("Received: " + person);
}
public static class Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return this.name;
}
}
} add the |
Thank you for the help. |
One more question. kafkaTracing = KafkaTracing.newBuilder(tracing) What is this tracing variable? I´m current using the sleuth to control the tracing ID and Span ID. |
We're already instrumenting that for you. You don't have to create this bean. We describe in the documentation how we use Brave (https://cloud.spring.io/spring-cloud-static/Finchley.RC2/single/spring-cloud.html#_introduction_to_brave). You can read about what
Please read the documentation. If you check the latest docs and you search for what you've asked you will find this section https://cloud.spring.io/spring-cloud-sleuth/single/spring-cloud-sleuth.html#_current_span |
For example: I have a code like this:
If I want tos end trace information through the kafka do a consumer, Is this what I have to do?
If that´s correct, how can I get the current traceing? |
No, that's completely incorrect. I wrote to you
And you have created the object yourself. Just use the
I don't understand this question. If you want the current tracer just autowire it. I think we describe this in the documentation? Can you please read it? |
Sorry for asking so many questions, but I´m stucked at this for some time, and I´m still in the dark. I read that these traces can only be propagated through kafka versions >0.11.0. Is that true? |
I have no idea what you're doing, but it might be somewhat related to #1005 . With Finchley, Spring Cloud Stream Kafka binder uses 0.11 and automatically propagates the header. From what I know in Kafka 0.10 there was no notion of headers as such cc @artembilan |
That's correct. You need to upgrade to Apache Kafka >= 0.11. That's from where it has started to support headers. Spring Kafka will propagate them all for you then automatically. Therefore these tracing headers will go from the producer over Kafka to consumer transparently for you. I'm afraid we can do nothing for you in that old Kafka version. See more info in the Spring Kafka Reference Manual: https://docs.spring.io/spring-kafka/docs/2.1.6.RELEASE/reference/html/_reference.html#headers |
@artembilan and @marcingrzejszczak, thanks for the informations. So, I´ve my kafka updated to version 2.12-1.1.0. Now, it´s ready for headers. As told by @marcingrzejszczak, I´ve changed my aplication to, I´ve rewrite the producer and the consumer, but I still can´t see the traceID beeng propagated through kafka. At my pom, I have the following:
The application.properties is:
The consumer code is like bellow:
And the consumer:
Executing the code, I can see the following logs: Producer:
Consumer:
So, we can see that the producer and consumer TraceIDs are different. And at the consumer, I can´t see nothing at the headers, even the custom header i´ve inserted manually at the producer. |
Not sure what is your Pay attention that we rely there on the Also you need to be sure that your Kafka Broker is exactly newer version, but not Also see Compatibility Matrix: https://spring.io/projects/spring-kafka#overview. The Spring Kafka I know this is tough, but there is no choice with Kafka if you would like more features. |
I'm sorry but this is a very simple feature that has been working since day one. You have to simplify your example and post it on github after following the guidlines from @artembilan . E.g. your snippets don't even compile (where did you take |
@danielsouza85 Remove your sensitive info in your application.properties, you've got host, passwords everything on the configuration properties exposed to public unnecessary. |
Hi! Seems this issue went off-course with unrelated issues for a moment; coming back on topic I would also like to use plain Now I'm puzzled; can anyone either confirm this works, or point out the flaw in my example project? If there's documentation to be updated that would also be helpful, although I wouldn't really know what to add or where. Any help appreciated. :) |
It just works #1088 |
Hello, I´m new with kafka and sleuth. And I´m having some problems on tracing a producer and a consumer over kafka.
I have one microservice that put some messages into a kafka topic, and the same microservice has a consumer, listening the same topic.
The first part is working just fine, but when the listener consume the message, the log shows no traceID, spanID. Everithing is empty.
I´ve enabled the debug for sleuth and at the producer part, I can see lots of debug messages, but at the consumer part, the only thing that was show is the log, without any trace information.
Here is the consumer code:
And the Logs with debug enabled:
----> Producer Part
----> Consumer Part
The text was updated successfully, but these errors were encountered: