From 856e0d0535b8af7359fc913fa40c1e59fca31abd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 21 Apr 2021 10:02:57 +0200 Subject: [PATCH] Document that MeterFilters are only applied to a managed registry Closes gh-25610 --- .../src/docs/asciidoc/production-ready-features.adoc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index 4290885d0e1..178fefb027d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -2139,15 +2139,15 @@ include::{code-examples}/actuate/metrics/SampleMeterBinderConfiguration.java[tag ---- Using a `MeterBinder` ensures that the correct dependency relationships are set up and that the bean is available when the metric's value is retrieved. -By default, metrics from all `MeterBinder` beans will be automatically bound to the Spring-managed `MeterRegistry`. A `MeterBinder` implementation can also be useful if you find that you repeatedly instrument a suite of metrics across components or applications. +NOTE: By default, metrics from all `MeterBinder` beans will be automatically bound to the Spring-managed `MeterRegistry`. + [[production-ready-metrics-per-meter-properties]] === Customizing individual metrics If you need to apply customizations to specific `Meter` instances you can use the `io.micrometer.core.instrument.config.MeterFilter` interface. -By default, all `MeterFilter` beans will be automatically applied to the micrometer `MeterRegistry.Config`. For example, if you want to rename the `mytag.region` tag to `mytag.area` for all meter IDs beginning with `com.example`, you can do the following: @@ -2156,6 +2156,10 @@ For example, if you want to rename the `mytag.region` tag to `mytag.area` for al include::{code-examples}/actuate/metrics/MetricsFilterBeanExample.java[tag=configuration] ---- +NOTE: By default, all `MeterFilter` beans will be automatically bound to the Spring-managed `MeterRegistry`. +Make sure to register your metrics using the Spring-managed `MeterRegistry` and not any of the static methods on `Metrics`. +These use the global registry that is not Spring-managed. + [[production-ready-metrics-common-tags]]