Skip to content

Commit

Permalink
Add section about Kafka metrics support
Browse files Browse the repository at this point in the history
Closes gh-21910
  • Loading branch information
snicoll committed Jun 15, 2020
1 parent ee250e0 commit 7500f0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions spring-boot-project/spring-boot-docs/build.gradle
Expand Up @@ -189,6 +189,7 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
"spring-data-rest-version": versionConstraints["org.springframework.data:spring-data-rest-core"],
"spring-data-solr-version": versionConstraints["org.springframework.data:spring-data-solr"],
"spring-framework-version": versionConstraints["org.springframework:spring-core"],
"spring-kafka-version": versionConstraints["org.springframework.kafka:spring-kafka"],
"spring-integration-version": versionConstraints["org.springframework.integration:spring-integration-core"],
"spring-security-version": versionConstraints["org.springframework.security:spring-security-core"],
"spring-webservices-version": versionConstraints["org.springframework.ws:spring-ws-core"]
Expand Down
Expand Up @@ -86,6 +86,7 @@
:spring-initializr-docs: https://docs.spring.io/initializr/docs/current/reference/html
:spring-integration: https://spring.io/projects/spring-integration
:spring-integration-docs: https://docs.spring.io/spring-integration/docs/{spring-integration-version}/reference/html/
:spring-kafka-docs: https://docs.spring.io/spring-kafka/docs/{spring-kafka-version}/reference/html/
:spring-restdocs: https://spring.io/projects/spring-restdocs
:spring-security: https://spring.io/projects/spring-security
:spring-security-docs: https://docs.spring.io/spring-security/site/docs/{spring-security-version}/reference/html5/
Expand Down
Expand Up @@ -1820,7 +1820,7 @@ Spring Boot registers the following core metrics when applicable:
** Number of classes loaded/unloaded
* CPU metrics
* File descriptor metrics
* Kafka consumer metrics
* Kafka consumer and producer metrics
* Log4j2 metrics: record the number of events logged to Log4j2 at each level
* Logback metrics: record the number of events logged to Logback at each level
* Uptime metrics: report a gauge for uptime and a fixed gauge representing the application's absolute start time
Expand Down Expand Up @@ -2069,6 +2069,13 @@ Auto-configuration will enable the instrumentation of all available RabbitMQ con



[[production-ready-metrics-kafka]]
==== Kafka Metrics
Auto-configuration will register a `MicrometerConsumerListener` and `MicrometerProducerListener` for the auto-configured consumer factory and producer factory respectively.
For more details refer to {spring-kafka-docs}#micrometer-native[Micrometer Native Metrics] section of the Spring Kafka documentation.



[[production-ready-metrics-custom]]
=== Registering custom metrics
To register custom metrics, inject `MeterRegistry` into your component, as shown in the following example:
Expand Down
Expand Up @@ -5728,7 +5728,7 @@ IMPORTANT: Properties set in this way override any configuration item that Sprin
==== Testing with Embedded Kafka
Spring for Apache Kafka provides a convenient way to test projects with an embedded Apache Kafka broker.
To use this feature, annotate a test class with `@EmbeddedKafka` from the `spring-kafka-test` module.
For more information, please see the Spring for Apache Kafka https://docs.spring.io/spring-kafka/docs/current/reference/html/#embedded-kafka-annotation[reference manual].
For more information, please see the Spring for Apache Kafka {spring-kafka-docs}#embedded-kafka-annotation[reference manual].

To make Spring Boot auto-configuration work with the aforementioned embedded Apache Kafka broker, you need to remap a system property for embedded broker addresses (populated by the `EmbeddedKafkaBroker`) into the Spring Boot configuration property for Apache Kafka.
There are several ways to do that:
Expand Down

0 comments on commit 7500f0f

Please sign in to comment.