Repository: camel Updated Branches: refs/heads/master a55d94524 -> ac64e160c
CAMEL-9365: camel-metrics - Allow to configure naming pattern for route policy Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ac64e160 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ac64e160 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ac64e160 Branch: refs/heads/master Commit: ac64e160c5ba3f5060557e6d7c4eb345c70355a3 Parents: a55d945 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Nov 25 18:22:45 2015 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Nov 25 18:22:45 2015 +0100 ---------------------------------------------------------------------- .../metrics/routepolicy/MetricsRoutePolicy.java | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ac64e160/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java ---------------------------------------------------------------------- diff --git a/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java b/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java index 74ae017..4269f01 100644 --- a/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java +++ b/components/camel-metrics/src/main/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicy.java @@ -42,6 +42,7 @@ public class MetricsRoutePolicy extends RoutePolicySupport { private TimeUnit durationUnit = TimeUnit.MILLISECONDS; private MetricsStatistics statistics; private Route route; + private String namePattern = "##name##.##routeId##.##type##"; private static final class MetricsStatistics { private final String routeId; @@ -113,6 +114,20 @@ public class MetricsRoutePolicy extends RoutePolicySupport { this.durationUnit = durationUnit; } + public String getNamePattern() { + return namePattern; + } + + /** + * The name pattern to use. + * <p/> + * Uses dot as separators, but you can change that. + * The values <tt>##name##</tt>, <tt>##routeId##</tt>, and <tt>##type##</tt> will be replaced with actual value. + */ + public void setNamePattern(String namePattern) { + this.namePattern = namePattern; + } + @Override public void onInit(Route route) { super.onInit(route); @@ -144,8 +159,13 @@ public class MetricsRoutePolicy extends RoutePolicySupport { private String createName(String type) { CamelContext context = route.getRouteContext().getCamelContext(); String name = context.getManagementName() != null ? context.getManagementName() : context.getName(); - // use colon to separate context from route, and dot for the type name - return name + ":" + route.getId() + "." + type; + + String answer = namePattern; + answer = answer.replaceFirst("##name##", name); + answer = answer.replaceFirst("##routeId##", route.getId()); + answer = answer.replaceFirst("##type##", type); + // use dot to separate context from route, and dot for the type name + return answer; } @Override