camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-7696: camel-metrics - Add a route policy to expose route stats as codehale metrics.
Date Sat, 06 Sep 2014 13:49:51 GMT
Repository: camel
Updated Branches:
  refs/heads/master c39f2cedb -> 213614233


CAMEL-7696: camel-metrics - Add a route policy to expose route stats as codehale metrics.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/21361423
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/21361423
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/21361423

Branch: refs/heads/master
Commit: 21361423329923c528125b7d88bbe813f18de9e6
Parents: c39f2ce
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Sep 6 15:31:01 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Sep 6 15:31:01 2014 +0200

----------------------------------------------------------------------
 .../metrics/routepolicy/MetricsRoutePolicy.java | 23 ++++----------------
 .../ManagedMetricsRoutePolicyTest.java          | 14 +++++-------
 .../routepolicy/MetricsRoutePolicyTest.java     |  4 ++--
 3 files changed, 12 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/21361423/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 d28044a..68c247a 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
@@ -18,8 +18,6 @@ package org.apache.camel.component.metrics.routepolicy;
 
 import java.util.concurrent.TimeUnit;
 
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Meter;
 import com.codahale.metrics.MetricRegistry;
 import com.codahale.metrics.Timer;
 import org.apache.camel.CamelContext;
@@ -46,30 +44,18 @@ public class MetricsRoutePolicy extends RoutePolicySupport {
     private Route route;
 
     private static final class MetricsStatistics {
-        private Counter total;
-        private Counter inflight;
-        private Meter requests;
         private Timer responses;
 
-        private MetricsStatistics(Counter total, Counter inflight, Meter requests, Timer
responses) {
-            this.total = total;
-            this.inflight = inflight;
-            this.requests = requests;
+        private MetricsStatistics(Timer responses) {
             this.responses = responses;
         }
 
         public void onExchangeBegin(Exchange exchange) {
-            total.inc();
-            inflight.inc();
-            requests.mark();
-
             Timer.Context context = responses.time();
             exchange.setProperty("MetricsRoutePolicy", context);
         }
 
         public void onExchangeDone(Exchange exchange) {
-            inflight.dec();
-
             Timer.Context context = exchange.getProperty("MetricsRoutePolicy", Timer.Context.class);
             if (context != null) {
                 context.stop();
@@ -147,11 +133,10 @@ public class MetricsRoutePolicy extends RoutePolicySupport {
         }
 
         // create statistics holder
-        Counter total = registryService.getMetricsRegistry().counter(createName("total"));
-        Counter inflight = registryService.getMetricsRegistry().counter(createName("inflight"));
-        Meter requests = registryService.getMetricsRegistry().meter(createName("requests"));
+        // for know we record only all the timings of a complete exchange (responses)
+        // we have in-flight / total statistics already from camel-core
         Timer responses = registryService.getMetricsRegistry().timer(createName("responses"));
-        statistics = new MetricsStatistics(total, inflight, requests, responses);
+        statistics = new MetricsStatistics(responses);
     }
 
     private String createName(String type) {

http://git-wip-us.apache.org/repos/asf/camel/blob/21361423/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/ManagedMetricsRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/ManagedMetricsRoutePolicyTest.java
b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/ManagedMetricsRoutePolicyTest.java
index 209ca9c..03c5c8f 100644
--- a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/ManagedMetricsRoutePolicyTest.java
+++ b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/ManagedMetricsRoutePolicyTest.java
@@ -66,12 +66,12 @@ public class ManagedMetricsRoutePolicyTest extends CamelTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        // there should be 2x4 names
-        assertEquals(8, registry.getNames().size());
+        // there should be 2 names
+        assertEquals(2, registry.getNames().size());
 
-        // there should be 8 mbeans
+        // there should be 2 mbeans
         Set<ObjectName> set = getMBeanServer().queryNames(new ObjectName("org.apache.camel.metrics:*"),
null);
-        assertEquals(8, set.size());
+        assertEquals(2, set.size());
 
         String name = String.format("org.apache.camel:context=%s,type=services,name=MetricsRegistryService",
context.getManagementName());
         ObjectName on = ObjectName.getInstance(name);
@@ -79,10 +79,8 @@ public class ManagedMetricsRoutePolicyTest extends CamelTestSupport {
         assertNotNull(json);
         log.info(json);
 
-        assertTrue(json.contains("foo.total"));
-        assertTrue(json.contains("bar.total"));
-        assertTrue(json.contains("bar.requests"));
-        assertTrue(json.contains("foo.requests"));
+        assertTrue(json.contains("bar.responses"));
+        assertTrue(json.contains("foo.responses"));
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/21361423/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicyTest.java
b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicyTest.java
index 09ec230..fef37a0 100644
--- a/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicyTest.java
+++ b/components/camel-metrics/src/test/java/org/apache/camel/component/metrics/routepolicy/MetricsRoutePolicyTest.java
@@ -52,8 +52,8 @@ public class MetricsRoutePolicyTest extends CamelTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        // there should be 2x4 names
-        assertEquals(8, registry.getNames().size());
+        // there should be 2 names
+        assertEquals(2, registry.getNames().size());
     }
 
     @Override


Mime
View raw message