camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [08/12] camel git commit: CAMEL-9759: camel-zipkin - Instrument Camel. Work in progress.
Date Tue, 29 Mar 2016 12:45:15 GMT
CAMEL-9759: camel-zipkin - Instrument Camel. Work in progress.


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

Branch: refs/heads/master
Commit: 5a92de6edb880b610c9c85d72a29175cdbe97e5c
Parents: a336ee9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Tue Mar 29 11:06:56 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Tue Mar 29 14:41:54 2016 +0200

----------------------------------------------------------------------
 .../zipkin/ZipkinClientRequestAdapter.java      |   4 +-
 .../camel/zipkin/ZipkinEventNotifier.java       | 191 ++++++++++++-------
 .../zipkin/ZipkinServerRequestAdapter.java      |   4 +-
 .../zipkin/scribe/ZipkinOneRouteScribe.java     |  80 ++++++++
 .../scribe/ZipkinRouteConcurrentScribe.java     |  10 +-
 .../zipkin/scribe/ZipkinSimpleRouteScribe.java  |   8 +-
 .../zipkin/scribe/ZipkinTimerRouteScribe.java   |  78 ++++++++
 .../src/test/resources/log4j.properties         |   4 +-
 8 files changed, 298 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinClientRequestAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinClientRequestAdapter.java
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinClientRequestAdapter.java
index 08e1679..e6e30477 100644
--- a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinClientRequestAdapter.java
+++ b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinClientRequestAdapter.java
@@ -64,7 +64,7 @@ public final class ZipkinClientRequestAdapter implements ClientRequestAdapter
{
 
     @Override
     public Collection<KeyValueAnnotation> requestAnnotations() {
-        String msgId = exchange.getIn().getMessageId();
-        return Collections.singletonList(KeyValueAnnotation.create("camel.message.id", msgId));
+        String id = exchange.getExchangeId();
+        return Collections.singletonList(KeyValueAnnotation.create("camel.exchange.id", id));
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinEventNotifier.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinEventNotifier.java
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinEventNotifier.java
index 97c57c2..ad0742e 100644
--- a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinEventNotifier.java
+++ b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinEventNotifier.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.zipkin;
 
+import java.io.Closeable;
 import java.util.EventObject;
 import java.util.HashMap;
 import java.util.Map;
@@ -23,6 +24,8 @@ import java.util.Map;
 import com.github.kristofa.brave.Brave;
 import com.github.kristofa.brave.ClientSpanThreadBinder;
 import com.github.kristofa.brave.Sampler;
+import com.github.kristofa.brave.ServerSpan;
+import com.github.kristofa.brave.ServerSpanThreadBinder;
 import com.github.kristofa.brave.SpanCollector;
 import com.twitter.zipkin.gen.Span;
 import org.apache.camel.CamelContext;
@@ -35,6 +38,8 @@ import org.apache.camel.management.event.ExchangeSendingEvent;
 import org.apache.camel.management.event.ExchangeSentEvent;
 import org.apache.camel.support.EventNotifierSupport;
 import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ServiceHelper;
 
 import static org.apache.camel.builder.ExpressionBuilder.routeIdExpression;
 
@@ -45,8 +50,8 @@ import static org.apache.camel.builder.ExpressionBuilder.routeIdExpression;
  * This means you need to configure which which Camel endpoints that maps to zipkin service
names.
  * The mapping can be configured using
  * <ul>
- *     <li>route id - A Camel route id</li>
- *     <li>endpoint url - A Camel endpoint url</li>
+ * <li>route id - A Camel route id</li>
+ * <li>endpoint url - A Camel endpoint url</li>
  * </ul>
  * For both kinds you can use wildcards and regular expressions to match, which is using
the rules from
  * {@link EndpointHelper#matchPattern(String, String)} and {@link EndpointHelper#matchEndpoint(CamelContext,
String, String)}
@@ -122,6 +127,19 @@ public class ZipkinEventNotifier extends EventNotifierSupport {
                 braves.put(serviceName, brave);
             }
         }
+
+        ServiceHelper.startService(spanCollector);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+
+        // stop and close collector
+        ServiceHelper.stopAndShutdownService(spanCollector);
+        if (spanCollector instanceof Closeable) {
+            IOHelper.close((Closeable) spanCollector);
+        }
     }
 
     @Override
@@ -134,16 +152,7 @@ public class ZipkinEventNotifier extends EventNotifierSupport {
         String answer = null;
 
         String id = routeIdExpression().evaluate(exchange, String.class);
-        for (Map.Entry<String, String> entry : serviceMappings.entrySet()) {
-            String pattern = entry.getKey();
-            if (EndpointHelper.matchPattern(pattern, id)) {
-                answer = entry.getValue();
-                break;
-            }
-        }
-
-        if (answer == null) {
-            id = exchange.getFromRouteId();
+        if (id != null) {
             for (Map.Entry<String, String> entry : serviceMappings.entrySet()) {
                 String pattern = entry.getKey();
                 if (EndpointHelper.matchPattern(pattern, id)) {
@@ -153,24 +162,41 @@ public class ZipkinEventNotifier extends EventNotifierSupport {
             }
         }
 
+        if (answer == null) {
+            id = exchange.getFromRouteId();
+            if (id != null) {
+                for (Map.Entry<String, String> entry : serviceMappings.entrySet())
{
+                    String pattern = entry.getKey();
+                    if (EndpointHelper.matchPattern(pattern, id)) {
+                        answer = entry.getValue();
+                        break;
+                    }
+                }
+            }
+        }
+
         if (answer == null && endpoint != null) {
             String url = endpoint.getEndpointUri();
-            for (Map.Entry<String, String> entry : serviceMappings.entrySet()) {
-                String pattern = entry.getKey();
-                if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern)) {
-                    answer = entry.getValue();
-                    break;
+            if (url != null) {
+                for (Map.Entry<String, String> entry : serviceMappings.entrySet())
{
+                    String pattern = entry.getKey();
+                    if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern))
{
+                        answer = entry.getValue();
+                        break;
+                    }
                 }
             }
         }
 
         if (answer == null && exchange.getFromEndpoint() != null) {
             String url = exchange.getFromEndpoint().getEndpointUri();
-            for (Map.Entry<String, String> entry : serviceMappings.entrySet()) {
-                String pattern = entry.getKey();
-                if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern)) {
-                    answer = entry.getValue();
-                    break;
+            if (url != null) {
+                for (Map.Entry<String, String> entry : serviceMappings.entrySet())
{
+                    String pattern = entry.getKey();
+                    if (EndpointHelper.matchEndpoint(exchange.getContext(), url, pattern))
{
+                        answer = entry.getValue();
+                        break;
+                    }
                 }
             }
         }
@@ -189,73 +215,98 @@ public class ZipkinEventNotifier extends EventNotifierSupport {
     @Override
     public void notify(EventObject event) throws Exception {
         if (event instanceof ExchangeSendingEvent) {
-            clientRequest((ExchangeSendingEvent) event);
+            ExchangeSendingEvent ese = (ExchangeSendingEvent) event;
+            String serviceName = getServiceName(ese.getExchange(), ese.getEndpoint());
+            Brave brave = getBrave(serviceName);
+            if (brave != null) {
+                clientRequest(brave, serviceName, ese);
+            }
         } else if (event instanceof ExchangeSentEvent) {
-            clientResponse((ExchangeSentEvent) event);
+            ExchangeSentEvent ese = (ExchangeSentEvent) event;
+            String serviceName = getServiceName(ese.getExchange(), ese.getEndpoint());
+            Brave brave = getBrave(serviceName);
+            if (brave != null) {
+                clientResponse(brave, serviceName, ese);
+            }
         } else if (event instanceof ExchangeCreatedEvent) {
-            serverRequest((ExchangeCreatedEvent) event);
+            ExchangeCreatedEvent ece = (ExchangeCreatedEvent) event;
+            String serviceName = getServiceName(ece.getExchange(), null);
+            Brave brave = getBrave(serviceName);
+            if (brave != null) {
+                serverRequest(brave, serviceName, ece);
+            }
         } else if (event instanceof ExchangeCompletedEvent) {
-            serverResponse((ExchangeCompletedEvent) event);
+            ExchangeCompletedEvent ece = (ExchangeCompletedEvent) event;
+            String serviceName = getServiceName(ece.getExchange(), null);
+            Brave brave = getBrave(serviceName);
+            if (brave != null) {
+                serverResponse(brave, serviceName, ece);
+            }
         } else if (event instanceof ExchangeFailedEvent) {
-            serverResponse((ExchangeFailedEvent) event);
+            ExchangeFailedEvent efe = (ExchangeFailedEvent) event;
+            String serviceName = getServiceName(efe.getExchange(), null);
+            Brave brave = getBrave(serviceName);
+            if (brave != null) {
+                serverResponse(brave, serviceName, efe);
+            }
         }
     }
 
-    private void clientRequest(ExchangeSendingEvent event) {
-        String serviceName = getServiceName(event.getExchange(), event.getEndpoint());
-        Brave brave = getBrave(serviceName);
-        if (brave != null) {
-            ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
-            brave.clientRequestInterceptor().handle(new ZipkinClientRequestAdapter(serviceName,
event.getExchange(), event.getEndpoint()));
-            Span span = binder.getCurrentClientSpan();
-            event.getExchange().setProperty("CamelZipkinSpan", span);
+    private void clientRequest(Brave brave, String serviceName, ExchangeSendingEvent event)
{
+        ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
+        brave.clientRequestInterceptor().handle(new ZipkinClientRequestAdapter(serviceName,
event.getExchange(), event.getEndpoint()));
+        Span span = binder.getCurrentClientSpan();
+        event.getExchange().setProperty("CamelZipkinClientSpan", span);
+
+        if (log.isDebugEnabled()) {
+            log.debug("clientRequest: service={}, id={} ", serviceName, span != null ? span.getId()
: "<null>");
         }
     }
 
-    private void clientResponse(ExchangeSentEvent event) {
-        String serviceName = getServiceName(event.getExchange(), event.getEndpoint());
-        Brave brave = getBrave(serviceName);
-        if (brave != null) {
-            ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
-            Span span = event.getExchange().getProperty("CamelZipkinSpan", Span.class);
-            binder.setCurrentSpan(span);
-            brave.clientResponseInterceptor().handle(new ZipkinClientResponseAdaptor(event.getExchange(),
event.getEndpoint()));
-            binder.setCurrentSpan(null);
+    private void clientResponse(Brave brave, String serviceName, ExchangeSentEvent event)
{
+        ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
+        Span span = event.getExchange().getProperty("CamelZipkinClientSpan", Span.class);
+        binder.setCurrentSpan(span);
+        brave.clientResponseInterceptor().handle(new ZipkinClientResponseAdaptor(event.getExchange(),
event.getEndpoint()));
+        binder.setCurrentSpan(null);
+
+        if (log.isDebugEnabled()) {
+            log.debug("clientResponse: service={}, id={} ", serviceName, span != null ? span.getId()
: "<null>");
         }
     }
 
-    private void serverRequest(ExchangeCreatedEvent event) {
-        String serviceName = getServiceName(event.getExchange(), null);
-        Brave brave = getBrave(serviceName);
-        if (brave != null) {
-            ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
-            brave.serverRequestInterceptor().handle(new ZipkinServerRequestAdapter(event.getExchange()));
-            Span span = binder.getCurrentClientSpan();
-            event.getExchange().setProperty("CamelZipkinSpan", span);
+    private void serverRequest(Brave brave, String serviceName, ExchangeCreatedEvent event)
{
+        ServerSpanThreadBinder binder = brave.serverSpanThreadBinder();
+        brave.serverRequestInterceptor().handle(new ZipkinServerRequestAdapter(event.getExchange()));
+        ServerSpan span = binder.getCurrentServerSpan();
+        event.getExchange().setProperty("CamelZipkinServerSpan", span);
+
+        if (log.isDebugEnabled()) {
+            log.debug("serverRequest: service={}, id={} ", serviceName, span != null ? span.getSpan().getId()
: "<null>");
         }
     }
 
-    private void serverResponse(ExchangeCompletedEvent event) {
-        String serviceName = getServiceName(event.getExchange(), null);
-        Brave brave = getBrave(serviceName);
-        if (brave != null) {
-            ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
-            Span span = event.getExchange().getProperty("CamelZipkinSpan", Span.class);
-            binder.setCurrentSpan(span);
-            brave.serverResponseInterceptor().handle(new ZipkinServerResponseAdapter(event.getExchange()));
-            binder.setCurrentSpan(null);
+    private void serverResponse(Brave brave, String serviceName, ExchangeCompletedEvent event)
{
+        ServerSpanThreadBinder binder = brave.serverSpanThreadBinder();
+        ServerSpan span = event.getExchange().getProperty("CamelZipkinServerSpan", ServerSpan.class);
+        binder.setCurrentSpan(span);
+        brave.serverResponseInterceptor().handle(new ZipkinServerResponseAdapter(event.getExchange()));
+        binder.setCurrentSpan(null);
+
+        if (log.isDebugEnabled()) {
+            log.debug("serverResponse: service={}, id={} ", serviceName, span != null ? span.getSpan().getId()
: "<null>");
         }
     }
 
-    private void serverResponse(ExchangeFailedEvent event) {
-        String serviceName = getServiceName(event.getExchange(), null);
-        Brave brave = getBrave(serviceName);
-        if (brave != null) {
-            ClientSpanThreadBinder binder = brave.clientSpanThreadBinder();
-            Span span = event.getExchange().getProperty("CamelZipkinSpan", Span.class);
-            binder.setCurrentSpan(span);
-            brave.serverResponseInterceptor().handle(new ZipkinServerResponseAdapter(event.getExchange()));
-            binder.setCurrentSpan(null);
+    private void serverResponse(Brave brave, String serviceName, ExchangeFailedEvent event)
{
+        ServerSpanThreadBinder binder = brave.serverSpanThreadBinder();
+        ServerSpan span = event.getExchange().getProperty("CamelZipkinServerSpan", ServerSpan.class);
+        binder.setCurrentSpan(span);
+        brave.serverResponseInterceptor().handle(new ZipkinServerResponseAdapter(event.getExchange()));
+        binder.setCurrentSpan(null);
+
+        if (log.isDebugEnabled()) {
+            log.debug("serverResponse: service={}, id={} ", serviceName, span != null ? span.getSpan().getId()
: "<null>");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerRequestAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerRequestAdapter.java
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerRequestAdapter.java
index fa67ddb..c5daef9 100644
--- a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerRequestAdapter.java
+++ b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerRequestAdapter.java
@@ -62,8 +62,8 @@ public class ZipkinServerRequestAdapter implements ServerRequestAdapter
{
 
     @Override
     public Collection<KeyValueAnnotation> requestAnnotations() {
-        String msgId = exchange.getIn().getMessageId();
-        return Collections.singletonList(KeyValueAnnotation.create("camel.message.id", msgId));
+        String id = exchange.getExchangeId();
+        return Collections.singletonList(KeyValueAnnotation.create("camel.exchange.id", id));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinOneRouteScribe.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinOneRouteScribe.java
b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinOneRouteScribe.java
new file mode 100644
index 0000000..c14a026
--- /dev/null
+++ b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinOneRouteScribe.java
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ * <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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.zipkin.scribe;
+
+import java.util.concurrent.TimeUnit;
+
+import com.github.kristofa.brave.scribe.ScribeSpanCollector;
+import org.apache.camel.CamelContext;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.zipkin.ZipkinEventNotifier;
+import org.junit.Test;
+
+/**
+ * Integration test requires running Zipkin/Scribe running
+ *
+ * The easiest way is to run using zipkin-docker: https://github.com/openzipkin/docker-zipkin
+ *
+ * Adjust the IP address to what IP docker-machines have assigned, you can use
+ * <tt>docker-machines ls</tt>
+ */
+public class ZipkinOneRouteScribe extends CamelTestSupport {
+
+    private String ip = "192.168.99.100";
+    private ZipkinEventNotifier zipkin;
+
+    // TODO: producer template also
+    // TODO: message id added x2
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        zipkin = new ZipkinEventNotifier();
+        zipkin.addServiceMapping("seda:cat", "cat");
+        zipkin.setSpanCollector(new ScribeSpanCollector(ip, 9410));
+        context.getManagementStrategy().addEventNotifier(zipkin);
+
+        return context;
+    }
+
+    @Test
+    public void testZipkinRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
+
+        for (int i = 0; i < 1; i++) {
+            template.sendBody("seda:cat", "Hello Cat");
+        }
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:cat").routeId("cat")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(1000,2000)}"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinRouteConcurrentScribe.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinRouteConcurrentScribe.java
b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinRouteConcurrentScribe.java
index d371547..65fdfdf 100644
--- a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinRouteConcurrentScribe.java
+++ b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinRouteConcurrentScribe.java
@@ -31,9 +31,13 @@ import org.junit.Test;
  * Integration test requires running Zipkin/Scribe running
  *
  * The easiest way is to run using zipkin-docker: https://github.com/openzipkin/docker-zipkin
+ *
+ * Adjust the IP address to what IP docker-machines have assigned, you can use
+ * <tt>docker-machines ls</tt>
  */
 public class ZipkinRouteConcurrentScribe extends CamelTestSupport {
 
+    private String ip = "192.168.99.100";
     private ZipkinEventNotifier zipkin;
 
     @Override
@@ -43,7 +47,7 @@ public class ZipkinRouteConcurrentScribe extends CamelTestSupport {
         zipkin = new ZipkinEventNotifier();
         zipkin.addServiceMapping("seda:foo", "foo");
         zipkin.addServiceMapping("seda:bar", "bar");
-        zipkin.setSpanCollector(new ScribeSpanCollector("192.168.99.101", 9410));
+        zipkin.setSpanCollector(new ScribeSpanCollector(ip, 9410));
         context.getManagementStrategy().addEventNotifier(zipkin);
 
         return context;
@@ -65,12 +69,12 @@ public class ZipkinRouteConcurrentScribe extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:foo").routeId("foo")
+                from("seda:foo?concurrentConsumers=5").routeId("foo")
                         .log("routing at ${routeId}")
                         .delay(simple("${random(1000,2000)}"))
                         .to("seda:bar");
 
-                from("seda:bar").routeId("bar")
+                from("seda:bar?concurrentConsumers=5").routeId("bar")
                         .log("routing at ${routeId}")
                         .delay(simple("${random(0,500)}"));
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinSimpleRouteScribe.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinSimpleRouteScribe.java
b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinSimpleRouteScribe.java
index 3d91927..fc898c8 100644
--- a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinSimpleRouteScribe.java
+++ b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinSimpleRouteScribe.java
@@ -31,9 +31,13 @@ import org.junit.Test;
  * Integration test requires running Zipkin/Scribe running
  *
  * The easiest way is to run using zipkin-docker: https://github.com/openzipkin/docker-zipkin
+ *
+ * Adjust the IP address to what IP docker-machines have assigned, you can use
+ * <tt>docker-machines ls</tt>
  */
 public class ZipkinSimpleRouteScribe extends CamelTestSupport {
 
+    private String ip = "192.168.99.100";
     private ZipkinEventNotifier zipkin;
 
     @Override
@@ -42,7 +46,7 @@ public class ZipkinSimpleRouteScribe extends CamelTestSupport {
 
         zipkin = new ZipkinEventNotifier();
         zipkin.addServiceMapping("seda:dude", "dude");
-        zipkin.setSpanCollector(new ScribeSpanCollector("192.168.99.101", 9410));
+        zipkin.setSpanCollector(new ScribeSpanCollector(ip, 9410));
         context.getManagementStrategy().addEventNotifier(zipkin);
 
         return context;
@@ -50,7 +54,7 @@ public class ZipkinSimpleRouteScribe extends CamelTestSupport {
 
     @Test
     public void testZipkinRoute() throws Exception {
-        NotifyBuilder notify = new NotifyBuilder(context).whenDone(10).create();
+        NotifyBuilder notify = new NotifyBuilder(context).whenDone(5).create();
 
         for (int i = 0; i < 5; i++) {
             template.sendBody("seda:dude", "Hello World");

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinTimerRouteScribe.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinTimerRouteScribe.java
b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinTimerRouteScribe.java
new file mode 100644
index 0000000..a822b08
--- /dev/null
+++ b/components/camel-zipkin/src/test/java/org/apache/camel/zipkin/scribe/ZipkinTimerRouteScribe.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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
+ * <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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.zipkin.scribe;
+
+import java.util.concurrent.TimeUnit;
+
+import com.github.kristofa.brave.scribe.ScribeSpanCollector;
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.zipkin.ZipkinEventNotifier;
+import org.junit.Test;
+
+/**
+ * Integration test requires running Zipkin/Scribe running
+ *
+ * The easiest way is to run using zipkin-docker: https://github.com/openzipkin/docker-zipkin
+ *
+ * Adjust the IP address to what IP docker-machines have assigned, you can use
+ * <tt>docker-machines ls</tt>
+ */
+public class ZipkinTimerRouteScribe extends CamelTestSupport {
+
+    private String ip = "192.168.99.100";
+    private ZipkinEventNotifier zipkin;
+
+    // TODO: producer template also (add a skip flag)
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        zipkin = new ZipkinEventNotifier();
+        zipkin.addServiceMapping("seda:timer", "timer");
+        zipkin.setSpanCollector(new ScribeSpanCollector(ip, 9410));
+        context.getManagementStrategy().addEventNotifier(zipkin);
+
+        return context;
+    }
+
+    @Test
+    public void testZipkinRoute() throws Exception {
+        NotifyBuilder notify = new NotifyBuilder(context).from("seda:timer").whenDone(1).create();
+
+        assertTrue(notify.matches(30, TimeUnit.SECONDS));
+    }
+
+    @Override
+    protected RoutesBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:trigger?repeatCount=1").setBody().constant("Hello Cat").to(ExchangePattern.InOut,
"seda:timer");
+
+                from("seda:timer").routeId("timer")
+                        .log("routing at ${routeId}")
+                        .delay(simple("${random(1000,2000)}"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/5a92de6e/components/camel-zipkin/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/test/resources/log4j.properties b/components/camel-zipkin/src/test/resources/log4j.properties
index 5d05c44..538c5bd 100644
--- a/components/camel-zipkin/src/test/resources/log4j.properties
+++ b/components/camel-zipkin/src/test/resources/log4j.properties
@@ -18,10 +18,10 @@
 #
 # The logging properties used
 #
-log4j.rootLogger=INFO, file
+log4j.rootLogger=INFO, out
 
 #log4j.logger.org.apache.camel=DEBUG
-#log4j.logger.org.apache.camel.zipkin=DEBUG
+log4j.logger.org.apache.camel.zipkin=DEBUG
 #log4j.logger.com.github.kristofa.brave=DEBUG
 
 # CONSOLE appender not used by default


Mime
View raw message