Kafka instrumentation enhancements (#1936)

* Bump javadocs since version to 3.1.0

* Extend integration tests to cover all Kafka clients

* Add autoconfiguration module for kafka instrumentation

* Refactor instrumentation for reactive Kafka Receiver

* Refactor instrumentation for reactive Kafka Receiver

* Add docs for Kafka instrumentation

* Revert "Refactor instrumentation for reactive Kafka Receiver"

This reverts commit 58c8f2fa

* Revert "Revert "Refactor instrumentation for reactive Kafka Receiver""

This reverts commit 450a9f8c

* Remove empty test

* Resolve comments from PR 1936

* Revert whitespaces

* Revert whitespaces in common tests pom.xml

* Fix autoconfig to consider generics when registering beans.
Only register reactor-kafka beans if the dependency is on the classpath.

* Split autoconfig for kafka and reactor-kafka
This commit is contained in:
Flaviu Mureșan
2021-05-07 22:20:37 +02:00
committed by GitHub
parent 507e918c39
commit 59c170d147
32 changed files with 1266 additions and 232 deletions

View File

@@ -77,6 +77,7 @@ Need more details about {project-full-name}'s core features?
Finally, we have topics related to instrumentation integrations:
* *Integrations:*
<<integrations.adoc#sleuth-kafka-integration, Apache Kafka>> |
<<integrations.adoc#sleuth-async-integration, Asynchronous Communication>> |
<<integrations.adoc#sleuth-http-client-integration, HTTP Client Integration>> |
<<integrations.adoc#sleuth-http-server-integration, HTTP Server Integration>> |
@@ -91,4 +92,4 @@ Finally, we have topics related to instrumentation integrations:
<<integrations.adoc#sleuth-runnablecallable-integration, Runnable and Callable>> |
<<integrations.adoc#sleuth-rxjava-integration, RxJava>> |
<<integrations.adoc#sleuth-circuitbreaker-integration, Spring Cloud CircuitBreaker>> |
<<integrations.adoc#sleuth-quartz-integration, Quartz>>
<<integrations.adoc#sleuth-quartz-integration, Quartz>>

View File

@@ -5,6 +5,25 @@ include::_attributes.adoc[]
In this section, we describe how to customize various parts of Spring Cloud Sleuth.
[[sleuth-kafka-integration]]
== Apache Kafka
This feature is available for all tracer implementations.
We decorate the Kafka clients (`KafkaProducer` and `KafkaConsumer`) to create a span for each event that is produced or consumed. You can disable this feature by setting the value of `spring.sleuth.kafka.enabled` to `false`.
IMPORTANT: You have to register the `Producer` or `Consumer` as beans in order for Sleuth's auto-configuration to decorate them. When you then inject the beans, the expected type must be `Producer` or `Consumer` (and NOT e.g. `KafkaProducer`).
We also provide `TracingKafkaProducerFactory` and `TracingKafkaConsumerFactory` to be used with the https://projectreactor.io/docs/kafka/release/reference/[Reactor Kafka] clients (`KafkaSender` and `KafkaReceiver`, respectively). See an example in the snippet below:
[source,java,indent=0]
----
@Bean
KafkaReceiver<String, String> reactiveKafkaReceiver(TracingKafkaConsumerFactory tracingKafkaConsumerFactory, KafkaReceiverOptions kafkaReceiverOptions) {
return KafkaReceiver.create(tracingKafkaConsumerFactory, kafkaReceiverOptions);
}
----
[[sleuth-async-integration]]
== Asynchronous Communication