@@ -244,7 +244,7 @@ include::{test-examples}/Api.java[tag=connection-recovery-back-off]
244
244
It is also possible to deactivate topology recovery if it is not appropriate for a given application.
245
245
The application would usually register a connection <<lifecycle-listeners,lifecycle listener>> to know when the connection is recovered and recover its own state accordingly.
246
246
247
- .Deactivate topology recovery
247
+ .Deactivating topology recovery
248
248
[source,java,indent=0]
249
249
--------
250
250
include::{test-examples}/Api.java[tag=connection-recovery-no-topology-recovery]
@@ -254,13 +254,84 @@ include::{test-examples}/Api.java[tag=connection-recovery-no-topology-recovery]
254
254
255
255
It is also possible to deactivate recovery altogether:
256
256
257
- .Deactivate recovery
257
+ .Deactivating recovery
258
258
[source,java,indent=0]
259
259
--------
260
260
include::{test-examples}/Api.java[tag=connection-recovery-deactivate]
261
261
--------
262
262
<1> Deactivate recovery
263
263
264
+ === Metrics Collection
265
+
266
+ The library provides the {javadoc-url}/com/rabbitmq/model/metrics/MetricsCollector.html[`MetricsCollector`] abstraction to collect metrics.
267
+ A `MetricsCollector` instance is set at the environment level and is called in several places by the library.
268
+ The underlying implementation can then collect, compute and expose metrics.
269
+
270
+ The library provides the `MicrometerMetricsCollector`, an implementation based on https://micrometer.io/[Micrometer].
271
+ Micrometer is a façade for observability systems: the user can choose the Micrometer meter registry for their favorite system.
272
+
273
+ Here is how to set up the Micrometer metrics collector and configure it for Prometheus:
274
+
275
+ .Setting metrics collection with Prometheus
276
+ [source,java,indent=0]
277
+ --------
278
+ include::{test-examples}/Api.java[tag=metrics-micrometer-prometheus]
279
+ --------
280
+ <1> Create the Micrometer meter registry for Prometheus
281
+ <2> Create the metrics collector with the registry
282
+ <3> Set the metrics collector in the environment builder
283
+ <4> Create a connection, a Micrometer gauge is incremented
284
+
285
+ The following metrics are recorded:
286
+
287
+ * the number of open connections
288
+ * the number of open publishers
289
+ * the number of open consumers
290
+ * the total number of published messages
291
+ * the total number of accepted published messages
292
+ * the total number of failed published messages
293
+ * the total number of consumed messages
294
+ * the total number of accepted consumed messages
295
+ * the total number of requeued consumed messages
296
+ * the total number of discarded consumed messages
297
+
298
+ Here is an example of the Prometheus output:
299
+
300
+ .Example of the Prometheus output
301
+ [source,prometheus]
302
+ ------
303
+ # HELP rabbitmq_amqp_connections
304
+ # TYPE rabbitmq_amqp_connections gauge
305
+ rabbitmq_amqp_connections 1.0
306
+ # HELP rabbitmq_amqp_consumed_total
307
+ # TYPE rabbitmq_amqp_consumed_total counter
308
+ rabbitmq_amqp_consumed_total 3.0
309
+ # HELP rabbitmq_amqp_consumed_accepted_total
310
+ # TYPE rabbitmq_amqp_consumed_accepted_total counter
311
+ rabbitmq_amqp_consumed_accepted_total 1.0
312
+ # HELP rabbitmq_amqp_consumed_discarded_total
313
+ # TYPE rabbitmq_amqp_consumed_discarded_total counter
314
+ rabbitmq_amqp_consumed_discarded_total 1.0
315
+ # HELP rabbitmq_amqp_consumed_requeued_total
316
+ # TYPE rabbitmq_amqp_consumed_requeued_total counter
317
+ rabbitmq_amqp_consumed_requeued_total 1.0
318
+ # HELP rabbitmq_amqp_consumers
319
+ # TYPE rabbitmq_amqp_consumers gauge
320
+ rabbitmq_amqp_consumers 1.0
321
+ # HELP rabbitmq_amqp_published_total
322
+ # TYPE rabbitmq_amqp_published_total counter
323
+ rabbitmq_amqp_published_total 2.0
324
+ # HELP rabbitmq_amqp_published_accepted_total
325
+ # TYPE rabbitmq_amqp_published_accepted_total counter
326
+ rabbitmq_amqp_published_accepted_total 1.0
327
+ # HELP rabbitmq_amqp_published_failed_total
328
+ # TYPE rabbitmq_amqp_published_failed_total counter
329
+ rabbitmq_amqp_published_failed_total 1.0
330
+ # HELP rabbitmq_amqp_publishers
331
+ # TYPE rabbitmq_amqp_publishers gauge
332
+ rabbitmq_amqp_publishers 1.0
333
+ ------
334
+
264
335
=== Remote Procedure Call (RPC)
265
336
266
337
Remote procedure call with RabbitMQ consists in a client sending a request message and a server replying with a response message.
0 commit comments