From fc53c0c39c1f363de1c27397383b8c57b8fdbb6f Mon Sep 17 00:00:00 2001 From: Clint Checketts Date: Fri, 3 Nov 2017 15:52:29 -0600 Subject: [PATCH] Add ID to filter 'configure' --- .../java/io/micrometer/core/instrument/MeterFilter.java | 6 ++++-- .../java/io/micrometer/core/instrument/MeterRegistry.java | 2 +- .../io/micrometer/core/instrument/MeterRegistryTest.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterFilter.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterFilter.java index 330119ffdf..373b96b434 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterFilter.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterFilter.java @@ -56,10 +56,12 @@ default Meter.Id map(Meter.Id id) { * This is only called when filtering new timers and distribution summaries (i.e. those meter types * that use {@link HistogramConfig}). * + * + * @param id Id with {@link MeterFilter#map} transformations applied. * @param config A histogram configuration guaranteed to be non-null. * @return Overrides to any part of the histogram config, when applicable. */ - default HistogramConfig configure(HistogramConfig config) { + default HistogramConfig configure(Meter.Id id, HistogramConfig config) { return config; } @@ -142,4 +144,4 @@ public MeterFilterReply accept(Meter.Id id) { static MeterFilter denyNameStartsWith(String prefix) { return deny(id -> id.getName().startsWith(prefix)); } -} \ No newline at end of file +} diff --git a/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java b/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java index 135fa2d4b2..c867c4d11d 100644 --- a/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java +++ b/micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java @@ -628,7 +628,7 @@ private M registerMeterIfNecessary(Class meterClass, Meter. HistogramConfig mappedConfig = config; if (mappedConfig != null) { for (MeterFilter filter : filters) { - mappedConfig = filter.configure(mappedConfig); + mappedConfig = filter.configure(mappedId, mappedConfig); } } diff --git a/micrometer-core/src/test/java/io/micrometer/core/instrument/MeterRegistryTest.java b/micrometer-core/src/test/java/io/micrometer/core/instrument/MeterRegistryTest.java index 8d992502e7..a2a719c35d 100644 --- a/micrometer-core/src/test/java/io/micrometer/core/instrument/MeterRegistryTest.java +++ b/micrometer-core/src/test/java/io/micrometer/core/instrument/MeterRegistryTest.java @@ -59,7 +59,7 @@ protected Timer newTimer(Meter.Id id, HistogramConfig histogramConfig) { registry.config().meterFilter(new MeterFilter() { @Override - public HistogramConfig configure(HistogramConfig config) { + public HistogramConfig configure(Meter.Id mappedId, HistogramConfig config) { return HistogramConfig.builder() .percentilesHistogram(true) .build() @@ -69,4 +69,4 @@ public HistogramConfig configure(HistogramConfig config) { registry.timer("my.timer"); } -} \ No newline at end of file +}