GH-3396: Add Docs for Micrometer MeterFilters
Resolves https://github.com/spring-projects/spring-integration/issues/3396 * Add an example.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
This section describes how to capture metrics for Spring Integration.
|
||||
In recent versions, we have relied more on Micrometer (see https://micrometer.io), and we plan to use Micrometer even more in future releases.
|
||||
|
||||
[[configuring-metrics-capture]]
|
||||
[[legacy-metrics]]
|
||||
==== Legacy Metrics
|
||||
|
||||
Legacy metrics were removed in Version 5.4; see Micrometer Integration below.
|
||||
@@ -48,6 +48,8 @@ IMPORTANT: `defaultLoggingEnabled` is applied only if you have not explicitly co
|
||||
[[micrometer-integration]]
|
||||
==== Micrometer Integration
|
||||
|
||||
===== Overview
|
||||
|
||||
Starting with version 5.0.3, the presence of a https://micrometer.io/[Micrometer] `MeterRegistry` in the application context triggers support for Micrometer metrics.
|
||||
|
||||
To use Micrometer, add one of the `MeterRegistry` beans to the application context.
|
||||
@@ -118,3 +120,34 @@ and
|
||||
* `tag`: `type:channel`
|
||||
* `tag`: `name:<componentName>`
|
||||
* `description`: `The remaining capacity of the queue channel`
|
||||
|
||||
===== Disabling Meters
|
||||
|
||||
With the <<legacy-metrics>> (which have now been removed), you could specify which integration components would collect metrics.
|
||||
By default, all meters are registered when first used.
|
||||
Now, with Micrometer, you can add `MeterFilter` s to the `MeterRegistry` to prevent some or all from being registered.
|
||||
You can filter out (deny) meters by any of the properties provided, `name`, `tag`, etc.
|
||||
See https://micrometer.io/docs/concepts#_meter_filters[Meter Filters] in the Micrometer documentation for more information.
|
||||
|
||||
For example, given:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
@Bean
|
||||
public QueueChannel noMeters() {
|
||||
return new QueueChannel(10);
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
You can suppress registration of meters for just this channel with:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
registry.config().meterFilter(MeterFilter.deny(id ->
|
||||
"channel".equals(id.getTag("type")) &&
|
||||
"noMeters".equals(id.getTag("name"))));
|
||||
----
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user