This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 043315469656bcc9f8c0c07868cda92bbd14f472
Author: Christian Ohr <christian....@gmail.com>
AuthorDate: Wed May 2 14:39:13 2018 +0200

    CAMEL-11600:make tests work
---
 .../micrometer/AbstractMicrometerProducer.java     |  24 ++-
 .../component/micrometer/CounterProducer.java      |  10 +-
 .../micrometer/DistributionSummaryProducer.java    |  11 +-
 .../component/micrometer/MicrometerComponent.java  |  21 +--
 .../component/micrometer/MicrometerEndpoint.java   |   8 +-
 .../camel/component/micrometer/TimerProducer.java  |  21 ++-
 .../messagehistory/MicrometerMessageHistory.java   |  13 +-
 .../spi/InstrumentedThreadPoolFactory.java         |  18 ++-
 .../spi/TimedScheduledExecutorService.java         |  17 +-
 .../micrometer/AbstractMicrometerProducerTest.java |  29 ++--
 .../component/micrometer/CounterProducerTest.java  |  48 +++---
 .../component/micrometer/CounterRouteTest.java     |  18 +--
 .../DistributionSummaryProducerTest.java           |  24 ++-
 .../micrometer/MetricComponentSpringTest.java      |  10 +-
 .../micrometer/MicrometerComponentTest.java        |  32 ++--
 .../component/micrometer/TimerEndpointTest.java    |  10 +-
 .../component/micrometer/TimerProducerTest.java    | 171 +++++----------------
 .../camel/component/micrometer/TimerRouteTest.java |  20 +--
 .../spi/InstrumentedThreadPoolFactoryTest.java     |  28 ++--
 19 files changed, 190 insertions(+), 343 deletions(-)

diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/AbstractMicrometerProducer.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/AbstractMicrometerProducer.java
index 6667681..da55499 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/AbstractMicrometerProducer.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/AbstractMicrometerProducer.java
@@ -27,7 +27,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
 import java.util.Optional;
 import java.util.function.Function;
 
@@ -60,8 +59,8 @@ public abstract class AbstractMicrometerProducer<T extends 
Meter> extends Defaul
         Message in = exchange.getIn();
         String defaultMetricsName = getEndpoint().getMetricsName();
         String finalMetricsName = getMetricsName(in, defaultMetricsName);
-        List<Tag> defaultTags = getEndpoint().getTags();
-        List<Tag> finalTags = getTags(in, defaultTags);
+        Iterable<Tag> defaultTags = getEndpoint().getTags();
+        Iterable<Tag> finalTags = getTags(in, defaultTags);
         try {
             doProcess(exchange, finalMetricsName, finalTags);
         } catch (Exception e) {
@@ -71,11 +70,9 @@ public abstract class AbstractMicrometerProducer<T extends 
Meter> extends Defaul
         }
     }
 
-    protected abstract Function<Search, T> search();
+    protected abstract Function<MeterRegistry, T> registrar(String name, 
Iterable<Tag> tags);
 
-    protected abstract Function<MeterRegistry, T> register(String name, 
List<Tag> tags);
-
-    protected void doProcess(Exchange exchange, String name, List<Tag> tags) {
+    protected void doProcess(Exchange exchange, String name, Iterable<Tag> 
tags) {
         T meter = getMeter(name, tags);
         try {
             doProcess(exchange, getEndpoint(), meter);
@@ -86,12 +83,9 @@ public abstract class AbstractMicrometerProducer<T extends 
Meter> extends Defaul
         }
     }
 
-    protected T getMeter(String name, List<Tag> tags) {
+    protected T getMeter(String name, Iterable<Tag> tags) {
         MeterRegistry registry = getEndpoint().getRegistry();
-        return Optional.ofNullable(
-                search().apply(registry.find(name))
-        ).orElseGet(() ->
-                register(name, tags).apply(registry));
+        return registrar(name, tags).apply(registry);
     }
 
     protected abstract void doProcess(Exchange exchange, MicrometerEndpoint 
endpoint, T meter);
@@ -100,7 +94,7 @@ public abstract class AbstractMicrometerProducer<T extends 
Meter> extends Defaul
         return getStringHeader(in, MicrometerConstants.HEADER_METRIC_NAME, 
defaultValue);
     }
 
-    public List<Tag> getTags(Message in, List<Tag> defaultTags) {
+    public Iterable<Tag> getTags(Message in, Iterable<Tag> defaultTags) {
         return getTagHeader(in, MicrometerConstants.HEADER_METRIC_TAGS, 
defaultTags);
     }
 
@@ -117,8 +111,8 @@ public abstract class AbstractMicrometerProducer<T extends 
Meter> extends Defaul
         return in.getHeader(header, defaultValue, Double.class);
     }
 
-    public List<Tag> getTagHeader(Message in, String header, List<Tag> 
defaultTags) {
-        return in.getHeader(header, defaultTags, List.class);
+    public Iterable<Tag> getTagHeader(Message in, String header, Iterable<Tag> 
defaultTags) {
+        return in.getHeader(header, defaultTags, Iterable.class);
     }
 
     protected boolean clearMetricsHeaders(Message in) {
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/CounterProducer.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/CounterProducer.java
index 19793ea..127a283 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/CounterProducer.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/CounterProducer.java
@@ -19,12 +19,9 @@ package org.apache.camel.component.micrometer;
 import io.micrometer.core.instrument.Counter;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.Tag;
-import io.micrometer.core.instrument.search.Search;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 
-import java.util.List;
-import java.util.Optional;
 import java.util.function.Function;
 
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_COUNTER_DECREMENT;
@@ -37,12 +34,7 @@ public class CounterProducer extends 
AbstractMicrometerProducer<Counter> {
     }
 
     @Override
-    protected Function<Search, Counter> search() {
-        return Search::counter;
-    }
-
-    @Override
-    protected Function<MeterRegistry, Counter> register(String name, List<Tag> 
tags) {
+    protected Function<MeterRegistry, Counter> registrar(String name, 
Iterable<Tag> tags) {
         return meterRegistry -> meterRegistry.counter(name, tags);
     }
 
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/DistributionSummaryProducer.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/DistributionSummaryProducer.java
index f6b5299..2b26d31 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/DistributionSummaryProducer.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/DistributionSummaryProducer.java
@@ -19,14 +19,10 @@ package org.apache.camel.component.micrometer;
 import io.micrometer.core.instrument.DistributionSummary;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.Tag;
-import io.micrometer.core.instrument.search.Search;
 import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-import java.util.Optional;
 import java.util.function.Function;
 
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_HISTOGRAM_VALUE;
@@ -40,12 +36,7 @@ public class DistributionSummaryProducer extends 
AbstractMicrometerProducer<Dist
     }
 
     @Override
-    protected Function<Search, DistributionSummary> search() {
-        return Search::summary;
-    }
-
-    @Override
-    protected Function<MeterRegistry, DistributionSummary> register(String 
name, List<Tag> tags) {
+    protected Function<MeterRegistry, DistributionSummary> registrar(String 
name, Iterable<Tag> tags) {
         return meterRegistry -> meterRegistry.summary(name, tags);
     }
 
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerComponent.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerComponent.java
index 9c02404..5dcf6ae 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerComponent.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerComponent.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.micrometer;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.Metrics;
 import io.micrometer.core.instrument.Tag;
+import io.micrometer.core.instrument.Tags;
 import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
 import org.apache.camel.Endpoint;
 import org.apache.camel.RuntimeCamelException;
@@ -33,6 +34,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.function.BinaryOperator;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -67,7 +69,7 @@ public class MicrometerComponent extends UriEndpointComponent 
{
         }
         String metricsName = getMetricsName(remaining, prefix);
         MetricsType metricsType = getMetricsType(remaining);
-        List<Tag> tags = getMetricsTag(parameters);
+        Iterable<Tag> tags = getMetricsTag(parameters);
 
         LOG.debug("Metrics type: {}; name: {}; tags: {}", metricsType, 
metricsName, tags);
         Endpoint endpoint = new MicrometerEndpoint(uri, this, metricsRegistry, 
metricsType, metricsName, tags);
@@ -94,16 +96,15 @@ public class MicrometerComponent extends 
UriEndpointComponent {
         return type;
     }
 
-    List<Tag> getMetricsTag(Map<String, Object> parameters) {
-        String tagString = getAndRemoveParameter(parameters, "tags", 
String.class, "");
-        if (tagString != null && !tagString.isEmpty()) {
-            String[] tags = tagString.split("/s*,/s*");
-            return Stream.of(tags)
-                    .map(s -> s.split(":"))
-                    .map(s -> Tag.of(s[0], s[1]))
-                    .collect(Collectors.toList());
+    Iterable<Tag> getMetricsTag(Map<String, Object> parameters) {
+        String tagsString = getAndRemoveParameter(parameters, "tags", 
String.class, "");
+        if (tagsString != null && !tagsString.isEmpty()) {
+            String[] tagStrings = tagsString.split("\\s*,\\s*");
+            return Stream.of(tagStrings)
+                    .map(s -> Tags.of(s.split("\\s*=\\s*")))
+                    .reduce(Tags.empty(), Tags::and);
         }
-        return Collections.emptyList();
+        return Tags.empty();
     }
 
     MeterRegistry getOrCreateMeterRegistry(Registry camelRegistry, String 
registryName) {
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerEndpoint.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerEndpoint.java
index 2d37f24..4e398cf 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerEndpoint.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/MicrometerEndpoint.java
@@ -25,8 +25,6 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 
-import java.util.List;
-
 /**
  * To collect various metrics directly from Camel routes using the DropWizard 
metrics library.
  */
@@ -42,7 +40,7 @@ public class MicrometerEndpoint extends DefaultEndpoint {
     @Metadata(required = "true")
     protected final String metricsName;
     @UriPath(description = "Tags of metrics")
-    protected final List<Tag> tags;
+    protected final Iterable<Tag> tags;
     @UriParam(description = "Action when using timer type")
     private MicrometerTimerAction action;
     @UriParam(description = "Value value when using histogram type")
@@ -52,7 +50,7 @@ public class MicrometerEndpoint extends DefaultEndpoint {
     @UriParam(description = "Decrement value when using counter type")
     private Double decrement;
 
-    public MicrometerEndpoint(String uri, Component component, MeterRegistry 
registry, MetricsType metricsType, String metricsName, List<Tag> tags) {
+    public MicrometerEndpoint(String uri, Component component, MeterRegistry 
registry, MetricsType metricsType, String metricsName, Iterable<Tag> tags) {
         super(uri, component);
         this.registry = registry;
         this.metricsType = metricsType;
@@ -91,7 +89,7 @@ public class MicrometerEndpoint extends DefaultEndpoint {
         return metricsName;
     }
 
-    public List<Tag> getTags() {
+    public Iterable<Tag> getTags() {
         return tags;
     }
 
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/TimerProducer.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/TimerProducer.java
index e174b63..837b521 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/TimerProducer.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/TimerProducer.java
@@ -19,13 +19,11 @@ package org.apache.camel.component.micrometer;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.Tag;
 import io.micrometer.core.instrument.Timer;
-import io.micrometer.core.instrument.search.Search;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
 import java.util.function.Function;
 
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_TIMER_ACTION;
@@ -39,12 +37,7 @@ public class TimerProducer extends 
AbstractMicrometerProducer<Timer> {
     }
 
     @Override
-    protected Function<Search, Timer> search() {
-        return Search::timer;
-    }
-
-    @Override
-    protected Function<MeterRegistry, Timer> register(String name, List<Tag> 
tags) {
+    protected Function<MeterRegistry, Timer> registrar(String name, 
Iterable<Tag> tags) {
         return meterRegistry -> meterRegistry.timer(name, tags);
     }
 
@@ -57,7 +50,7 @@ public class TimerProducer extends 
AbstractMicrometerProducer<Timer> {
     }
 
     @Override
-    protected void doProcess(Exchange exchange, String metricsName, List<Tag> 
tags) {
+    protected void doProcess(Exchange exchange, String metricsName, 
Iterable<Tag> tags) {
         MeterRegistry registry = getEndpoint().getRegistry();
         Message in = exchange.getIn();
         MicrometerTimerAction action = getEndpoint().getAction();
@@ -65,14 +58,18 @@ public class TimerProducer extends 
AbstractMicrometerProducer<Timer> {
         if (finalAction == MicrometerTimerAction.start) {
             handleStart(exchange, registry, metricsName);
         } else if (finalAction == MicrometerTimerAction.stop) {
-            if (getTimerSampleFromExchange(exchange, 
getPropertyName(metricsName)) != null) {
-                doProcess(exchange, getEndpoint(), getMeter(metricsName, 
tags));
-            }
+            handleStop(exchange, metricsName, tags);
         } else {
             LOG.warn("No action provided for timer \"{}\"", metricsName);
         }
     }
 
+    private void handleStop(Exchange exchange, String metricsName, 
Iterable<Tag> tags) {
+        if (getTimerSampleFromExchange(exchange, getPropertyName(metricsName)) 
!= null) {
+            doProcess(exchange, getEndpoint(), getMeter(metricsName, tags));
+        }
+    }
+
     void handleStart(Exchange exchange, MeterRegistry registry, String 
metricsName) {
         String propertyName = getPropertyName(metricsName);
         Timer.Sample sample = getTimerSampleFromExchange(exchange, 
propertyName);
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistory.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistory.java
index 200b204..266191a 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistory.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/messagehistory/MicrometerMessageHistory.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,11 @@
 package org.apache.camel.component.micrometer.messagehistory;
 
 import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.Tag;
 import io.micrometer.core.instrument.Timer;
 import org.apache.camel.MessageHistory;
 import org.apache.camel.NamedNode;
 import org.apache.camel.impl.DefaultMessageHistory;
 
-import java.time.Duration;
-import java.util.Arrays;
-
 /**
  * A micrometer metrics based {@link MessageHistory}
  */
@@ -35,9 +31,6 @@ public class MicrometerMessageHistory extends 
DefaultMessageHistory {
     private final MeterRegistry meterRegistry;
     private final String name;
 
-    private Duration minimumExpectedValue = Duration.ofMillis(1L);
-    private Duration maximumExpectedValue = Duration.ofSeconds(30L);
-
     public MicrometerMessageHistory(MeterRegistry meterRegistry, String 
routeId, NamedNode namedNode, String name, long timestamp) {
         super(routeId, namedNode, timestamp);
         this.meterRegistry = meterRegistry;
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactory.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactory.java
index 0120586..f071e1b 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactory.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactory.java
@@ -16,17 +16,19 @@
  */
 package org.apache.camel.component.micrometer.spi;
 
-import java.util.Collections;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicLong;
-
 import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
 import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics;
 import org.apache.camel.impl.DefaultThreadPoolFactory;
 import org.apache.camel.spi.ThreadPoolFactory;
 import org.apache.camel.spi.ThreadPoolProfile;
 import org.apache.camel.util.ObjectHelper;
 
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicLong;
+
 /**
  * This implements a {@link ThreadPoolFactory} and generates an Instrumented 
versions of ExecutorService used to
  * monitor performance of each thread using Metrics.
@@ -64,8 +66,8 @@ public class InstrumentedThreadPoolFactory implements 
ThreadPoolFactory {
     @Override
     public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile 
profile, ThreadFactory threadFactory) {
         ScheduledExecutorService executorService = 
threadPoolFactory.newScheduledThreadPool(profile, threadFactory);
-        new ExecutorServiceMetrics(executorService, name(profile.getId()), 
Collections.emptySet()).bindTo(meterRegistry);
-        return new TimedScheduledExecutorService(meterRegistry, 
executorService, name(prefix), Collections.emptySet());
+        String executorServiceName = name(profile.getId());
+        return new TimedScheduledExecutorService(meterRegistry, 
executorService, executorServiceName, Tags.empty());
     }
 
     public void setPrefix(String prefix) {
@@ -76,4 +78,8 @@ public class InstrumentedThreadPoolFactory implements 
ThreadPoolFactory {
         return prefix + counter.incrementAndGet();
     }
 
+    void reset() {
+        counter.set(0L);
+    }
+
 }
diff --git 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/TimedScheduledExecutorService.java
 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/TimedScheduledExecutorService.java
index f47248f..9f0b6ac 100644
--- 
a/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/TimedScheduledExecutorService.java
+++ 
b/components/camel-micrometer/src/main/java/org/apache/camel/component/micrometer/spi/TimedScheduledExecutorService.java
@@ -17,32 +17,35 @@ import java.util.concurrent.TimeUnit;
 public class TimedScheduledExecutorService extends TimedExecutorService 
implements ScheduledExecutorService {
 
     private final ScheduledExecutorService delegate;
-    private final Timer timer;
+    private final MeterRegistry registry;
 
     public TimedScheduledExecutorService(MeterRegistry registry, 
ScheduledExecutorService delegate, String executorServiceName, Iterable<Tag> 
tags) {
         super(registry, delegate, executorServiceName, tags);
+        this.registry = registry;
         this.delegate = delegate;
-        this.timer = registry.timer("executor",
-                Tags.concat(tags, "name", executorServiceName));
     }
 
     @Override
     public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit 
unit) {
-        return delegate.schedule(timer.wrap(command), delay, unit);
+        return delegate.schedule(meter().wrap(command), delay, unit);
     }
 
     @Override
     public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, 
TimeUnit unit) {
-        return delegate.schedule(timer.wrap(callable), delay, unit);
+        return delegate.schedule(meter().wrap(callable), delay, unit);
     }
 
     @Override
     public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long 
initialDelay, long period, TimeUnit unit) {
-        return delegate.scheduleAtFixedRate(timer.wrap(command), initialDelay, 
period, unit);
+        return delegate.scheduleAtFixedRate(meter().wrap(command), 
initialDelay, period, unit);
     }
 
     @Override
     public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long 
initialDelay, long delay, TimeUnit unit) {
-        return delegate.scheduleWithFixedDelay(timer.wrap(command), 
initialDelay, delay, unit);
+        return delegate.scheduleWithFixedDelay(meter().wrap(command), 
initialDelay, delay, unit);
+    }
+
+    private Timer meter() {
+        return registry.find("executor").timer();
     }
 }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/AbstractMicrometerProducerTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/AbstractMicrometerProducerTest.java
index 5343e5f..149dbee 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/AbstractMicrometerProducerTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/AbstractMicrometerProducerTest.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,7 +31,6 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 
-import java.util.List;
 import java.util.function.Function;
 
 import static 
org.apache.camel.component.micrometer.AbstractMicrometerProducer.HEADER_PATTERN;
@@ -59,23 +58,18 @@ public class AbstractMicrometerProducerTest {
     @Mock
     private MeterRegistry registry;
 
-    private AbstractMicrometerProducer okProducer;
+    private AbstractMicrometerProducer<Meter> okProducer;
 
-    private AbstractMicrometerProducer failProducer;
+    private AbstractMicrometerProducer<Meter> failProducer;
 
     private InOrder inOrder;
 
     @Before
     public void setUp() throws Exception {
-        okProducer = new AbstractMicrometerProducer(endpoint) {
+        okProducer = new AbstractMicrometerProducer<Meter>(endpoint) {
 
             @Override
-            protected Function search() {
-                return null;
-            }
-
-            @Override
-            protected Function register(String name, List list) {
+            protected Function registrar(String name, Iterable<Tag> list) {
                 return null;
             }
 
@@ -83,15 +77,10 @@ public class AbstractMicrometerProducerTest {
             protected void doProcess(Exchange exchange, MicrometerEndpoint 
endpoint, Meter meter) {
             }
         };
-        failProducer = new AbstractMicrometerProducer(endpoint) {
-
-            @Override
-            protected Function search() {
-                return null;
-            }
+        failProducer = new AbstractMicrometerProducer<Meter>(endpoint) {
 
             @Override
-            protected Function register(String name, List list) {
+            protected Function registrar(String name, Iterable<Tag> list) {
                 return null;
             }
 
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterProducerTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterProducerTest.java
index 79f84a1..431984b 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterProducerTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterProducerTest.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@ package org.apache.camel.component.micrometer;
 
 import io.micrometer.core.instrument.Counter;
 import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.search.Search;
+import io.micrometer.core.instrument.Tags;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.junit.Before;
@@ -29,8 +29,6 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 
-import java.util.Collections;
-
 import static 
org.apache.camel.component.micrometer.AbstractMicrometerProducer.HEADER_PATTERN;
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_COUNTER_DECREMENT;
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_COUNTER_INCREMENT;
@@ -55,9 +53,6 @@ public class CounterProducerTest {
     private MeterRegistry registry;
 
     @Mock
-    private Search search;
-
-    @Mock
     private Counter counter;
 
     @Mock
@@ -71,10 +66,9 @@ public class CounterProducerTest {
     public void setUp() throws Exception {
         endpoint = mock(MicrometerEndpoint.class);
         producer = new CounterProducer(endpoint);
-        inOrder = Mockito.inOrder(endpoint, exchange, registry, counter, 
search, in);
+        inOrder = Mockito.inOrder(endpoint, exchange, registry, counter, in);
         when(endpoint.getRegistry()).thenReturn(registry);
-        when(registry.find(METRICS_NAME)).thenReturn(search);
-        when(search.counter()).thenReturn(counter);
+        when(registry.counter(METRICS_NAME, Tags.empty())).thenReturn(counter);
         when(exchange.getIn()).thenReturn(in);
     }
 
@@ -89,10 +83,9 @@ public class CounterProducerTest {
         when(endpoint.getIncrement()).thenReturn(INCREMENT);
         when(endpoint.getDecrement()).thenReturn(null);
         when(in.getHeader(HEADER_COUNTER_INCREMENT, INCREMENT, 
Double.class)).thenReturn(INCREMENT);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
@@ -110,10 +103,9 @@ public class CounterProducerTest {
         when(endpoint.getIncrement()).thenReturn(null);
         when(endpoint.getDecrement()).thenReturn(DECREMENT);
         when(in.getHeader(HEADER_COUNTER_DECREMENT, DECREMENT, 
Double.class)).thenReturn(DECREMENT);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
@@ -132,10 +124,9 @@ public class CounterProducerTest {
         when(in.getHeader(HEADER_COUNTER_INCREMENT, INCREMENT, 
Double.class)).thenReturn(INCREMENT);
         when(in.getHeader(HEADER_COUNTER_DECREMENT, DECREMENT, 
Double.class)).thenReturn(DECREMENT);
 
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
@@ -152,10 +143,9 @@ public class CounterProducerTest {
         Object action = null;
         when(endpoint.getIncrement()).thenReturn(null);
         when(endpoint.getDecrement()).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
@@ -173,10 +163,9 @@ public class CounterProducerTest {
         when(endpoint.getDecrement()).thenReturn(DECREMENT);
         when(in.getHeader(HEADER_COUNTER_INCREMENT, INCREMENT, 
Double.class)).thenReturn(INCREMENT + 1);
         when(in.getHeader(HEADER_COUNTER_DECREMENT, DECREMENT, 
Double.class)).thenReturn(DECREMENT);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
@@ -194,10 +183,9 @@ public class CounterProducerTest {
         when(endpoint.getIncrement()).thenReturn(null);
         when(endpoint.getDecrement()).thenReturn(DECREMENT);
         when(in.getHeader(HEADER_COUNTER_DECREMENT, DECREMENT, 
Double.class)).thenReturn(DECREMENT - 1);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getRegistry();
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).counter();
+        inOrder.verify(registry, times(1)).counter(METRICS_NAME, Tags.empty());
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(endpoint, times(1)).getIncrement();
         inOrder.verify(endpoint, times(1)).getDecrement();
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterRouteTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterRouteTest.java
index 43bb056..dc4b5c0 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterRouteTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/CounterRouteTest.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.micrometer;
 
+import io.micrometer.core.instrument.Counter;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
 import org.apache.camel.EndpointInject;
@@ -35,16 +36,13 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.test.context.ContextConfiguration;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import static 
org.apache.camel.component.micrometer.MicrometerComponent.METRICS_REGISTRY;
 import static org.apache.camel.component.micrometer.MicrometerConstants.*;
 import static org.junit.Assert.assertEquals;
 
 @RunWith(CamelSpringRunner.class)
 @ContextConfiguration(
-        classes = { CounterRouteTest.TestConfig.class },
+        classes = {CounterRouteTest.TestConfig.class},
         loader = CamelSpringDelegatingTestContextLoader.class)
 @MockEndpoints
 public class CounterRouteTest {
@@ -92,7 +90,7 @@ public class CounterRouteTest {
 
                     from("direct:in-4")
                             .setHeader(HEADER_COUNTER_INCREMENT, 
simple("${body.length}"))
-                            .to("micrometer:counter:D")
+                            .to("micrometer:counter:D?tags=a=b")
                             .to("mock:out");
                 }
             };
@@ -151,7 +149,9 @@ public class CounterRouteTest {
         endpoint.expectedMessageCount(1);
         String message = "Hello from Camel Metrics!";
         producer4.sendBody(message);
-        assertEquals(message.length(), 
registry.find(MicrometerConstants.HEADER_PREFIX + "." + "D").counter().count(), 
0.01D);
+        Counter counter = registry.find(MicrometerConstants.HEADER_PREFIX + 
"." + "D").counter();
+        assertEquals(message.length(), counter.count(), 0.01D);
+        assertEquals("b", counter.getId().getTag("a"));
         endpoint.assertIsSatisfied();
     }
 }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/DistributionSummaryProducerTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/DistributionSummaryProducerTest.java
index 36e3ee5..d2669fd 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/DistributionSummaryProducerTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/DistributionSummaryProducerTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.micrometer;
 
 import io.micrometer.core.instrument.DistributionSummary;
 import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
 import io.micrometer.core.instrument.search.Search;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -52,9 +53,6 @@ public class DistributionSummaryProducerTest {
     private MeterRegistry registry;
 
     @Mock
-    private Search search;
-
-    @Mock
     private DistributionSummary histogram;
 
     @Mock
@@ -71,10 +69,9 @@ public class DistributionSummaryProducerTest {
     public void setUp() throws Exception {
         endpoint = mock(MicrometerEndpoint.class);
         producer = new DistributionSummaryProducer(endpoint);
-        inOrder = Mockito.inOrder(endpoint, registry, histogram, search, 
exchange, in);
+        inOrder = Mockito.inOrder(endpoint, registry, histogram, exchange, in);
         when(endpoint.getRegistry()).thenReturn(registry);
-        when(registry.find(METRICS_NAME)).thenReturn(search);
-        when(search.summary()).thenReturn(histogram);
+        when(registry.summary(METRICS_NAME, 
Tags.empty())).thenReturn(histogram);
         when(exchange.getIn()).thenReturn(in);
     }
 
@@ -87,9 +84,8 @@ public class DistributionSummaryProducerTest {
     public void testProcessValueSet() throws Exception {
         when(endpoint.getValue()).thenReturn(VALUE);
         when(in.getHeader(HEADER_HISTOGRAM_VALUE, VALUE, 
Double.class)).thenReturn(VALUE);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).summary();
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
+        inOrder.verify(registry, times(1)).summary(METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getValue();
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(in, times(1)).getHeader(HEADER_HISTOGRAM_VALUE, VALUE, 
Double.class);
@@ -103,9 +99,8 @@ public class DistributionSummaryProducerTest {
     public void testProcessValueNotSet() throws Exception {
         Object action = null;
         when(endpoint.getValue()).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).summary();
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
+        inOrder.verify(registry, times(1)).summary(METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getValue();
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(in, times(1)).getHeader(HEADER_HISTOGRAM_VALUE, action, 
Double.class);
@@ -118,9 +113,8 @@ public class DistributionSummaryProducerTest {
     public void testProcessOverrideValue() throws Exception {
         when(endpoint.getValue()).thenReturn(VALUE);
         when(in.getHeader(HEADER_HISTOGRAM_VALUE, VALUE, 
Double.class)).thenReturn(VALUE + 3.0d);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(registry, times(1)).find(METRICS_NAME);
-        inOrder.verify(search, times(1)).summary();
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
+        inOrder.verify(registry, times(1)).summary(METRICS_NAME, Tags.empty());
         inOrder.verify(endpoint, times(1)).getValue();
         inOrder.verify(exchange, times(1)).getIn();
         inOrder.verify(in, times(1)).getHeader(HEADER_HISTOGRAM_VALUE, VALUE, 
Double.class);
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MetricComponentSpringTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MetricComponentSpringTest.java
index b107550..4f70933 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MetricComponentSpringTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MetricComponentSpringTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.micrometer;
 
 import io.micrometer.core.instrument.Counter;
 import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
 import io.micrometer.core.instrument.search.Search;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
@@ -79,15 +80,12 @@ public class MetricComponentSpringTest {
     public void testMetricsRegistryFromCamelRegistry() throws Exception {
         MeterRegistry mockRegistry = 
endpoint.getCamelContext().getRegistry().lookupByNameAndType(MicrometerComponent.METRICS_REGISTRY,
 MeterRegistry.class);
         Counter mockCounter = Mockito.mock(Counter.class);
-        Search mockSearch = Mockito.mock(Search.class);
-        InOrder inOrder = Mockito.inOrder(mockRegistry, mockCounter, 
mockSearch);
-        when(mockRegistry.find(MicrometerConstants.HEADER_PREFIX + "." + 
"A")).thenReturn(mockSearch);
-        when(mockSearch.counter()).thenReturn(mockCounter);
+        InOrder inOrder = Mockito.inOrder(mockRegistry, mockCounter);
+        when(mockRegistry.counter(MicrometerConstants.HEADER_PREFIX + "." + 
"A", Tags.empty())).thenReturn(mockCounter);
         endpoint.expectedMessageCount(1);
         producer.sendBody(new Object());
         endpoint.assertIsSatisfied();
-        inOrder.verify(mockRegistry, 
times(1)).find(MicrometerConstants.HEADER_PREFIX + "." + "A");
-        inOrder.verify(mockSearch, times(1)).counter();
+        inOrder.verify(mockRegistry, 
times(1)).counter(MicrometerConstants.HEADER_PREFIX + "." + "A", Tags.empty());
         inOrder.verify(mockCounter, times(1)).increment(512D);
         inOrder.verifyNoMoreInteractions();
     }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MicrometerComponentTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MicrometerComponentTest.java
index 5c18a61..0b826f0 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MicrometerComponentTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/MicrometerComponentTest.java
@@ -63,7 +63,7 @@ public class MicrometerComponentTest {
     private MicrometerComponent component;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         component = new MicrometerComponent();
         inOrder = Mockito.inOrder(camelContext, camelRegistry, metricRegistry, 
typeConverter);
     }
@@ -73,11 +73,11 @@ public class MicrometerComponentTest {
         component.setCamelContext(camelContext);
         when(camelContext.getRegistry()).thenReturn(camelRegistry);
         when(camelContext.getTypeConverter()).thenReturn(typeConverter);
-        when(typeConverter.convertTo(String.class, 
"key:value")).thenReturn("key:value");
+        when(typeConverter.convertTo(String.class, 
"key=value")).thenReturn("key=value");
         
when(camelRegistry.lookupByNameAndType(MicrometerComponent.METRICS_REGISTRY, 
MeterRegistry.class)).thenReturn(metricRegistry);
 
         Map<String, Object> params = new HashMap<>();
-        params.put("tags", "key:value");
+        params.put("tags", "key=value");
         Endpoint result = 
component.createEndpoint("micrometer:counter:counter", "counter:counter", 
params);
         assertThat(result, is(notNullValue()));
         assertThat(result, is(instanceOf(MicrometerEndpoint.class)));
@@ -87,58 +87,58 @@ public class MicrometerComponentTest {
         inOrder.verify(camelContext, times(1)).getRegistry();
         inOrder.verify(camelRegistry, 
times(1)).lookupByNameAndType(MicrometerComponent.METRICS_REGISTRY, 
MeterRegistry.class);
         inOrder.verify(camelContext, times(1)).getTypeConverter();
-        inOrder.verify(typeConverter, times(1)).convertTo(String.class, 
"key:value");
+        inOrder.verify(typeConverter, times(1)).convertTo(String.class, 
"key=value");
         inOrder.verify(camelContext, times(1)).getTypeConverter();
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void testCreateNewEndpointForCounter() throws Exception {
+    public void testCreateNewEndpointForCounter() {
         Endpoint endpoint = new MicrometerEndpoint(null, null, metricRegistry, 
MetricsType.COUNTER, "a name", Collections.emptyList());
         assertThat(endpoint, is(notNullValue()));
         assertThat(endpoint, is(instanceOf(MicrometerEndpoint.class)));
     }
 
     @Test
-    public void testCreateNewEndpointForGauge() throws Exception {
+    public void testCreateNewEndpointForGauge() {
         MicrometerEndpoint endpoint = new MicrometerEndpoint(null, null, 
metricRegistry, MetricsType.GAUGE, "a name", Collections.emptyList());
         assertThat(endpoint, is(notNullValue()));
         assertThat(endpoint, is(instanceOf(MicrometerEndpoint.class)));
     }
 
     @Test
-    public void testCreateNewEndpointForHistogram() throws Exception {
+    public void testCreateNewEndpointForHistogram() {
         Endpoint endpoint = new MicrometerEndpoint(null, null, metricRegistry, 
MetricsType.DISTRIBUTION_SUMMARY, "a name", Collections.emptyList());
         assertThat(endpoint, is(notNullValue()));
         assertThat(endpoint, is(instanceOf(MicrometerEndpoint.class)));
     }
 
     @Test
-    public void testCreateNewEndpointForTimer() throws Exception {
+    public void testCreateNewEndpointForTimer() {
         Endpoint endpoint = new MicrometerEndpoint(null, null, metricRegistry, 
MetricsType.TIMER, "a name", Collections.emptyList());
         assertThat(endpoint, is(notNullValue()));
         assertThat(endpoint, is(instanceOf(MicrometerEndpoint.class)));
     }
 
     @Test
-    public void testGetMetricsType() throws Exception {
+    public void testGetMetricsType() {
         for (MetricsType type : EnumSet.allOf(MetricsType.class)) {
             assertThat(component.getMetricsType(type.toString() + 
":metrics-name"), is(type));
         }
     }
 
     @Test
-    public void testGetMetricsTypeNotSet() throws Exception {
+    public void testGetMetricsTypeNotSet() {
         assertThat(component.getMetricsType("no-metrics-type"), 
is(MicrometerComponent.DEFAULT_METER_TYPE));
     }
 
     @Test(expected = RuntimeCamelException.class)
-    public void testGetMetricsTypeNotFound() throws Exception {
+    public void testGetMetricsTypeNotFound() {
         component.getMetricsType("unknown-metrics:metrics-name");
     }
 
     @Test
-    public void testGetOrCreateMetricRegistryFoundInCamelRegistry() throws 
Exception {
+    public void testGetOrCreateMetricRegistryFoundInCamelRegistry() {
         when(camelRegistry.lookupByNameAndType("name", 
MeterRegistry.class)).thenReturn(metricRegistry);
         MeterRegistry result = 
component.getOrCreateMeterRegistry(camelRegistry, "name");
         assertThat(result, is(metricRegistry));
@@ -147,7 +147,7 @@ public class MicrometerComponentTest {
     }
 
     @Test
-    public void testGetOrCreateMetricRegistryFoundInCamelRegistryByType() 
throws Exception {
+    public void testGetOrCreateMetricRegistryFoundInCamelRegistryByType() {
         when(camelRegistry.lookupByNameAndType("name", 
MeterRegistry.class)).thenReturn(null);
         
when(camelRegistry.findByType(MeterRegistry.class)).thenReturn(Collections.singleton(metricRegistry));
         MeterRegistry result = 
component.getOrCreateMeterRegistry(camelRegistry, "name");
@@ -158,7 +158,7 @@ public class MicrometerComponentTest {
     }
 
     @Test
-    public void testGetOrCreateMetricRegistryNotFoundInCamelRegistry() throws 
Exception {
+    public void testGetOrCreateMetricRegistryNotFoundInCamelRegistry() {
         when(camelRegistry.lookupByNameAndType("name", 
MeterRegistry.class)).thenReturn(null);
         
when(camelRegistry.findByType(MeterRegistry.class)).thenReturn(Collections.<MeterRegistry>emptySet());
         MeterRegistry result = 
component.getOrCreateMeterRegistry(camelRegistry, "name");
@@ -170,7 +170,7 @@ public class MicrometerComponentTest {
     }
 
     @Test
-    public void testGetMetricRegistryFromCamelRegistry() throws Exception {
+    public void testGetMetricRegistryFromCamelRegistry() {
         when(camelRegistry.lookupByNameAndType("name", 
MeterRegistry.class)).thenReturn(metricRegistry);
         MeterRegistry result = 
component.getMeterRegistryFromCamelRegistry(camelRegistry, "name");
         assertThat(result, is(metricRegistry));
@@ -179,7 +179,7 @@ public class MicrometerComponentTest {
     }
 
     @Test
-    public void testCreateMetricRegistry() throws Exception {
+    public void testCreateMetricRegistry() {
         MeterRegistry registry = component.createMeterRegistry();
         assertThat(registry, is(notNullValue()));
     }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerEndpointTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerEndpointTest.java
index 620e760..b043877 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerEndpointTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerEndpointTest.java
@@ -48,18 +48,18 @@ public class TimerEndpointTest {
     private InOrder inOrder;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         endpoint = new MicrometerEndpoint(null, null, registry, 
MetricsType.TIMER, METRICS_NAME, Collections.emptyList());
         inOrder = Mockito.inOrder(registry);
     }
 
     @After
-    public void tearDown() throws Exception {
+    public void tearDown() {
         inOrder.verifyNoMoreInteractions();
     }
 
     @Test
-    public void testTimerEndpoint() throws Exception {
+    public void testTimerEndpoint() {
         assertThat(endpoint, is(notNullValue()));
         assertThat(endpoint.getRegistry(), is(registry));
         assertThat(endpoint.getMetricsName(), is(METRICS_NAME));
@@ -73,12 +73,12 @@ public class TimerEndpointTest {
     }
 
     @Test
-    public void testGetAction() throws Exception {
+    public void testGetAction() {
         assertThat(endpoint.getAction(), is(nullValue()));
     }
 
     @Test
-    public void testSetAction() throws Exception {
+    public void testSetAction() {
         assertThat(endpoint.getAction(), is(nullValue()));
         endpoint.setAction(MicrometerTimerAction.start);
         assertThat(endpoint.getAction(), is(MicrometerTimerAction.start));
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerProducerTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerProducerTest.java
index b727466..97856b7 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerProducerTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerProducerTest.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,28 +16,21 @@
  */
 package org.apache.camel.component.micrometer;
 
-import io.micrometer.core.instrument.Clock;
-import io.micrometer.core.instrument.MeterRegistry;
-import io.micrometer.core.instrument.Timer;
-import io.micrometer.core.instrument.search.Search;
+import io.micrometer.core.instrument.*;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.ArgumentMatchers;
-import org.mockito.InOrder;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 
 import java.util.Collections;
 
-import static 
org.apache.camel.component.micrometer.AbstractMicrometerProducer.HEADER_PATTERN;
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_TIMER_ACTION;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.when;
 
 @RunWith(MockitoJUnitRunner.class)
 public class TimerProducerTest {
@@ -61,9 +54,6 @@ public class TimerProducerTest {
     private Clock clock;
 
     @Mock
-    private Search search;
-
-    @Mock
     private Timer timer;
 
     @Mock
@@ -74,14 +64,10 @@ public class TimerProducerTest {
 
     private TimerProducer producer;
 
-    @Mock
-    private InOrder inOrder;
-
     @Before
     public void setUp() throws Exception {
         producer = new TimerProducer(endpoint);
-        inOrder = Mockito.inOrder(endpoint, exchange, registry, timer, sample, 
in, search, config, clock);
-
+        when(endpoint.getRegistry()).thenReturn(registry);
         when(exchange.getIn()).thenReturn(in);
     }
 
@@ -96,47 +82,9 @@ public class TimerProducerTest {
         when(endpoint.getAction()).thenReturn(MicrometerTimerAction.start);
         when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.start, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.start);
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, 
MicrometerTimerAction.start, MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(registry, times(1)).timer(METRICS_NAME);
-        // inOrder.verify(timer, times(1)).time();
-        inOrder.verify(exchange, times(1)).setProperty(PROPERTY_NAME, sample);
-        inOrder.verifyNoMoreInteractions();
-    }
-
-    @Test
-    public void testProcessStartWithOverride() throws Exception {
-        when(endpoint.getAction()).thenReturn(MicrometerTimerAction.start);
-        when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.start, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.stop);
-        when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, 
MicrometerTimerAction.start, MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(sample, times(1)).stop(timer);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
-    }
-
-    @Test
-    public void testProcessStop() throws Exception {
-        when(endpoint.getAction()).thenReturn(MicrometerTimerAction.stop);
-        when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.stop, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.stop);
-        when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, 
MicrometerTimerAction.stop, MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(sample, times(1)).stop(timer);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+        when(registry.config()).thenReturn(config);
+        when(config.clock()).thenReturn(clock);
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
     @Test
@@ -144,95 +92,58 @@ public class TimerProducerTest {
         when(endpoint.getAction()).thenReturn(MicrometerTimerAction.stop);
         when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.stop, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.start);
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, 
MicrometerTimerAction.stop, MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(registry, times(1)).timer(METRICS_NAME);
-        // inOrder.verify(timer, times(1)).time();
-        inOrder.verify(exchange, times(1)).setProperty(PROPERTY_NAME, sample);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+        when(registry.config()).thenReturn(config);
+        when(config.clock()).thenReturn(clock);
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
-    @Test
-    public void testProcessNoAction() throws Exception {
-        when(endpoint.getAction()).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, (Object) 
null, MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
-    }
 
     @Test
     public void testProcessNoActionOverride() throws Exception {
         Object action = null;
         when(endpoint.getAction()).thenReturn(null);
         when(in.getHeader(HEADER_TIMER_ACTION, action, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.start);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(endpoint, times(1)).getAction();
-        inOrder.verify(in, times(1)).getHeader(HEADER_TIMER_ACTION, action, 
MicrometerTimerAction.class);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(registry, times(1)).timer(METRICS_NAME);
-        // inOrder.verify(timer, times(1)).time();
-        inOrder.verify(exchange, times(1)).setProperty(PROPERTY_NAME, sample);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
-    }
-
-    @Test
-    public void testHandleStart() throws Exception {
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(null);
         when(registry.config()).thenReturn(config);
         when(config.clock()).thenReturn(clock);
-        
doNothing().when(exchange).setProperty(ArgumentMatchers.eq(METRICS_NAME), 
ArgumentMatchers.any(Timer.Sample.class));
-        producer.handleStart(exchange, registry, METRICS_NAME);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(exchange, 
times(1)).setProperty(ArgumentMatchers.eq(METRICS_NAME), 
ArgumentMatchers.any(Timer.Sample.class));
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
     @Test
-    public void testHandleStartAlreadyRunning() throws Exception {
+    public void testProcessStartWithOverride() throws Exception {
+        when(endpoint.getAction()).thenReturn(MicrometerTimerAction.start);
+        when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.start, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.stop);
+        when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
+        when(endpoint.getRegistry()).thenReturn(registry);
+        when(registry.timer(METRICS_NAME, Tags.empty())).thenReturn(timer);
+        when(timer.getId()).thenReturn(new Meter.Id(METRICS_NAME, 
Collections.emptyList(), null, null, Meter.Type.TIMER));
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
-        producer.handleStart(exchange, registry, METRICS_NAME);
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+        when(sample.stop(timer)).thenReturn(0L);
+        when(exchange.removeProperty(PROPERTY_NAME)).thenReturn(null);
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
     @Test
-    public void testHandleStop() throws Exception {
+    public void testProcessStop() throws Exception {
+        when(endpoint.getAction()).thenReturn(MicrometerTimerAction.stop);
+        when(in.getHeader(HEADER_TIMER_ACTION, MicrometerTimerAction.stop, 
MicrometerTimerAction.class)).thenReturn(MicrometerTimerAction.stop);
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(sample, times(1)).stop(timer);
-        inOrder.verify(exchange, times(1)).removeProperty(PROPERTY_NAME);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+        when(endpoint.getRegistry()).thenReturn(registry);
+        when(registry.timer(METRICS_NAME, Tags.empty())).thenReturn(timer);
+        when(timer.getId()).thenReturn(new Meter.Id(METRICS_NAME, 
Collections.emptyList(), null, null, Meter.Type.TIMER));
+        when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
+        when(sample.stop(timer)).thenReturn(0L);
+        when(exchange.removeProperty(PROPERTY_NAME)).thenReturn(null);
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
     @Test
-    public void testHandleStopContextNotFound() throws Exception {
-        when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(null);
-        producer.doProcess(exchange, METRICS_NAME, Collections.emptyList());
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        inOrder.verify(exchange, times(1)).getIn();
-        inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
+    public void testProcessNoAction() throws Exception {
+        when(endpoint.getAction()).thenReturn(null);
+        producer.doProcess(exchange, METRICS_NAME, Tags.empty());
     }
 
+
     @Test
     public void testGetPropertyName() throws Exception {
         assertThat(producer.getPropertyName(METRICS_NAME), is("timer" + ":" + 
METRICS_NAME));
@@ -242,19 +153,11 @@ public class TimerProducerTest {
     public void testGetTimerContextFromExchange() throws Exception {
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(sample);
         assertThat(producer.getTimerSampleFromExchange(exchange, 
PROPERTY_NAME), is(sample));
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        //inOrder.verify(exchange, times(1)).getIn();
-        //inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
     }
 
     @Test
     public void testGetTimerContextFromExchangeNotFound() throws Exception {
         when(exchange.getProperty(PROPERTY_NAME, 
Timer.Sample.class)).thenReturn(null);
         assertThat(producer.getTimerSampleFromExchange(exchange, 
PROPERTY_NAME), is(nullValue()));
-        inOrder.verify(exchange, times(1)).getProperty(PROPERTY_NAME, 
Timer.Sample.class);
-        //inOrder.verify(exchange, times(1)).getIn();
-        //inOrder.verify(in, times(1)).removeHeaders(HEADER_PATTERN);
-        inOrder.verifyNoMoreInteractions();
     }
 }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerRouteTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerRouteTest.java
index 8d5c5ba..d04a7c1 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerRouteTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/TimerRouteTest.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,11 +16,8 @@
  */
 package org.apache.camel.component.micrometer;
 
-import io.micrometer.core.instrument.Clock;
-import io.micrometer.core.instrument.Counter;
 import io.micrometer.core.instrument.MeterRegistry;
 import io.micrometer.core.instrument.Timer;
-import io.micrometer.core.instrument.search.Search;
 import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
@@ -35,8 +32,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.InOrder;
-import org.mockito.Mockito;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.test.context.ContextConfiguration;
@@ -48,12 +43,10 @@ import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_M
 import static 
org.apache.camel.component.micrometer.MicrometerConstants.HEADER_TIMER_ACTION;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.*;
-import static org.mockito.Mockito.mock;
 
 @RunWith(CamelSpringRunner.class)
 @ContextConfiguration(
-        classes = { TimerRouteTest.TestConfig.class },
+        classes = {TimerRouteTest.TestConfig.class},
         loader = CamelSpringDelegatingTestContextLoader.class)
 @MockEndpoints
 public class TimerRouteTest {
@@ -101,7 +94,7 @@ public class TimerRouteTest {
                     from("direct:in-3")
                             .to("micrometer:timer:C?action=start")
                             .delay(100L)
-                            .to("micrometer:timer:C?action=stop")
+                            .to("micrometer:timer:C?action=stop&tags=a=b")
                             .to("mock:out");
                 }
             };
@@ -151,9 +144,10 @@ public class TimerRouteTest {
         Object body = new Object();
         endpoint.expectedBodiesReceived(body);
         producer3.sendBody(body);
-        Timer timer = registry.find(MicrometerConstants.HEADER_PREFIX + "." + 
"A").timer();
+        Timer timer = registry.find(MicrometerConstants.HEADER_PREFIX + "." + 
"C").timer();
         assertEquals(1L, timer.count());
         assertTrue(timer.max(TimeUnit.MILLISECONDS) > 0.0D);
+        assertEquals("b", timer.getId().getTag("a"));
         endpoint.assertIsSatisfied();
     }
 }
diff --git 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactoryTest.java
 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactoryTest.java
index 5335657..ab0e770 100644
--- 
a/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactoryTest.java
+++ 
b/components/camel-micrometer/src/test/java/org/apache/camel/component/micrometer/spi/InstrumentedThreadPoolFactoryTest.java
@@ -17,10 +17,12 @@
 package org.apache.camel.component.micrometer.spi;
 
 import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.Tags;
 import io.micrometer.core.instrument.internal.TimedExecutorService;
 import org.apache.camel.ThreadPoolRejectedPolicy;
 import org.apache.camel.spi.ThreadPoolFactory;
 import org.apache.camel.spi.ThreadPoolProfile;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -37,12 +39,13 @@ import java.util.concurrent.TimeUnit;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.assertThat;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.times;
 
 @RunWith(MockitoJUnitRunner.class)
 public class InstrumentedThreadPoolFactoryTest {
 
-    private static final String METRICS_NAME = "metrics.name";
+    private static final String METRICS_NAME = "metrics.name.";
 
     @Mock
     private MeterRegistry registry;
@@ -60,7 +63,7 @@ public class InstrumentedThreadPoolFactoryTest {
     private InOrder inOrder;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         profile = new ThreadPoolProfile(METRICS_NAME);
         profile.setDefaultProfile(false);
         profile.setMaxPoolSize(10);
@@ -75,14 +78,19 @@ public class InstrumentedThreadPoolFactoryTest {
         inOrder = Mockito.inOrder(registry);
     }
 
+    @After
+    public void tearDown() {
+        instrumentedThreadPoolFactory.reset();
+    }
+
     @Test
-    public void testNewCacheThreadPool() throws Exception {
+    public void testNewCachedThreadPool() throws Exception {
         final ExecutorService executorService = 
instrumentedThreadPoolFactory.newCachedThreadPool(threadFactory);
         assertThat(executorService, is(notNullValue()));
         assertThat(executorService, 
is(instanceOf(TimedExecutorService.class)));
 
-        inOrder.verify(registry, times(1)).counter(anyString());
-        inOrder.verify(registry, times(1)).timer(anyString());
+        Tags tags = Tags.of("name", "instrumented-delegate-1");
+        inOrder.verify(registry, times(1)).timer("executor", tags);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -91,8 +99,8 @@ public class InstrumentedThreadPoolFactoryTest {
         final ExecutorService executorService = 
instrumentedThreadPoolFactory.newThreadPool(profile, threadFactory);
         assertThat(executorService, is(notNullValue()));
         assertThat(executorService, 
is(instanceOf(TimedExecutorService.class)));
-
-        inOrder.verify(registry, times(1)).timer("executor");
+        Tags tags = Tags.of("name", METRICS_NAME + "1");
+        inOrder.verify(registry, times(1)).timer("executor", tags);
         inOrder.verifyNoMoreInteractions();
     }
 
@@ -103,10 +111,8 @@ public class InstrumentedThreadPoolFactoryTest {
         assertThat(scheduledExecutorService, is(notNullValue()));
         assertThat(scheduledExecutorService, 
is(instanceOf(TimedExecutorService.class)));
 
-        inOrder.verify(registry, times(1)).counter("running");
-        inOrder.verify(registry, times(1)).timer("duration");
-        inOrder.verify(registry, times(1)).counter("scheduled.overrun");
-        inOrder.verify(registry, 
times(1)).summary("scheduled.percent-of-period");
+        Tags tags = Tags.of("name", METRICS_NAME + "1");
+        inOrder.verify(registry, times(1)).timer("executor", tags);
         inOrder.verifyNoMoreInteractions();
     }
 

-- 
To stop receiving notification emails like this one, please contact
acosent...@apache.org.

Reply via email to