camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [06/12] camel git commit: CAMEL-9759: camel-zipkin - Instrument Camel. Work in progress.
Date Tue, 29 Mar 2016 12:45:13 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/d4e9cc6b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d4e9cc6b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d4e9cc6b

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

----------------------------------------------------------------------
 .../apache/camel/zipkin/ZipkinClientRequestAdapter.java  | 11 +++++++++--
 .../apache/camel/zipkin/ZipkinServerRequestAdapter.java  | 11 +++++++++--
 .../apache/camel/zipkin/ZipkinServerResponseAdapter.java |  2 +-
 .../camel/zipkin/scribe/ZipkinTimerRouteScribe.java      |  6 +++---
 .../camel-zipkin/src/test/resources/log4j.properties     |  2 +-
 5 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d4e9cc6b/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 e6e30477..b3c80b1 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
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.zipkin;
 
+import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Locale;
 
 import com.github.kristofa.brave.ClientRequestAdapter;
@@ -35,12 +35,14 @@ public final class ZipkinClientRequestAdapter implements ClientRequestAdapter
{
     private final Exchange exchange;
     private final Endpoint endpoint;
     private final String spanName;
+    private final String url;
 
     public ZipkinClientRequestAdapter(String serviceName, Exchange exchange, Endpoint endpoint)
{
         this.serviceName = serviceName;
         this.exchange = exchange;
         this.endpoint = endpoint;
         this.spanName = URISupport.sanitizeUri(endpoint.getEndpointKey()).toLowerCase(Locale.US);
+        this.url = URISupport.sanitizeUri(endpoint.getEndpointUri());
     }
 
     @Override
@@ -65,6 +67,11 @@ public final class ZipkinClientRequestAdapter implements ClientRequestAdapter
{
     @Override
     public Collection<KeyValueAnnotation> requestAnnotations() {
         String id = exchange.getExchangeId();
-        return Collections.singletonList(KeyValueAnnotation.create("camel.exchange.id", id));
+        String mep = exchange.getPattern().name();
+
+        KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.client.endpoint.url",
url);
+        KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.client.exchange.id", id);
+        KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.client.exchange.pattern",
mep);
+        return Arrays.asList(key1, key2, key3);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d4e9cc6b/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 c5daef9..59c6b4f 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
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.zipkin;
 
+import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Locale;
 
 import com.github.kristofa.brave.KeyValueAnnotation;
@@ -35,11 +35,13 @@ public class ZipkinServerRequestAdapter implements ServerRequestAdapter
{
     private final Exchange exchange;
     private final Endpoint endpoint;
     private final String spanName;
+    private final String url;
 
     public ZipkinServerRequestAdapter(Exchange exchange) {
         this.exchange = exchange;
         this.endpoint = exchange.getFromEndpoint();
         this.spanName = URISupport.sanitizeUri(endpoint.getEndpointKey()).toLowerCase(Locale.US);
+        this.url = URISupport.sanitizeUri(endpoint.getEndpointUri());
     }
 
     @Override
@@ -63,7 +65,12 @@ public class ZipkinServerRequestAdapter implements ServerRequestAdapter
{
     @Override
     public Collection<KeyValueAnnotation> requestAnnotations() {
         String id = exchange.getExchangeId();
-        return Collections.singletonList(KeyValueAnnotation.create("camel.exchange.id", id));
+        String mep = exchange.getPattern().name();
+
+        KeyValueAnnotation key1 = KeyValueAnnotation.create("camel.server.endpoint.url",
url);
+        KeyValueAnnotation key2 = KeyValueAnnotation.create("camel.server.exchange.id", id);
+        KeyValueAnnotation key3 = KeyValueAnnotation.create("camel.server.exchange.pattern",
mep);
+        return Arrays.asList(key1, key2, key3);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d4e9cc6b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerResponseAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerResponseAdapter.java
b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerResponseAdapter.java
index 2ba8594..0a7035c 100644
--- a/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerResponseAdapter.java
+++ b/components/camel-zipkin/src/main/java/org/apache/camel/zipkin/ZipkinServerResponseAdapter.java
@@ -37,7 +37,7 @@ public class ZipkinServerResponseAdapter implements ServerResponseAdapter
{
     @Override
     public Collection<KeyValueAnnotation> responseAnnotations() {
         if (exchange.getException() != null) {
-            return Collections.singletonList(KeyValueAnnotation.create("camel.failure", exchange.getException().getMessage()));
+            return Collections.singletonList(KeyValueAnnotation.create("camel.server.failure",
exchange.getException().getMessage()));
         } else {
             return Collections.emptyList();
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/d4e9cc6b/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
index a822b08..017102c 100644
--- 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
@@ -41,8 +41,6 @@ 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();
@@ -59,6 +57,8 @@ public class ZipkinTimerRouteScribe extends CamelTestSupport {
     public void testZipkinRoute() throws Exception {
         NotifyBuilder notify = new NotifyBuilder(context).from("seda:timer").whenDone(1).create();
 
+        template.sendBody("direct:start", "Hello Timer");
+
         assertTrue(notify.matches(30, TimeUnit.SECONDS));
     }
 
@@ -67,7 +67,7 @@ public class ZipkinTimerRouteScribe extends CamelTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("timer:trigger?repeatCount=1").setBody().constant("Hello Cat").to(ExchangePattern.InOut,
"seda:timer");
+                from("direct:start").to(ExchangePattern.InOut, "seda:timer");
 
                 from("seda:timer").routeId("timer")
                         .log("routing at ${routeId}")

http://git-wip-us.apache.org/repos/asf/camel/blob/d4e9cc6b/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 538c5bd..ab7b29f 100644
--- a/components/camel-zipkin/src/test/resources/log4j.properties
+++ b/components/camel-zipkin/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
 #
 # The logging properties used
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
 
 #log4j.logger.org.apache.camel=DEBUG
 log4j.logger.org.apache.camel.zipkin=DEBUG


Mime
View raw message