Repository: karaf-decanter
Updated Branches:
  refs/heads/master 8e7ec6bc9 -> 41cdd8998


Add properties to include/exclude properties, headers, body in the Decanter 
Camel Tracer and Event Notifier


Project: http://git-wip-us.apache.org/repos/asf/karaf-decanter/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-decanter/commit/41cdd899
Tree: http://git-wip-us.apache.org/repos/asf/karaf-decanter/tree/41cdd899
Diff: http://git-wip-us.apache.org/repos/asf/karaf-decanter/diff/41cdd899

Branch: refs/heads/master
Commit: 41cdd8998b451ea4008f1d987b7da6ecc7369dcc
Parents: 8e7ec6b
Author: Jean-Baptiste Onofré <jbono...@apache.org>
Authored: Mon Jul 17 09:20:01 2017 +0200
Committer: Jean-Baptiste Onofré <jbono...@apache.org>
Committed: Mon Jul 17 09:20:01 2017 +0200

----------------------------------------------------------------------
 .../collector/camel/DecanterEventNotifier.java  | 35 ++++++++++++++++----
 .../camel/DecanterTraceEventHandler.java        | 35 ++++++++++++++++----
 2 files changed, 56 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/41cdd899/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterEventNotifier.java
----------------------------------------------------------------------
diff --git 
a/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterEventNotifier.java
 
b/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterEventNotifier.java
index 5c0769d..27d7e07 100644
--- 
a/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterEventNotifier.java
+++ 
b/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterEventNotifier.java
@@ -51,6 +51,9 @@ public class DecanterEventNotifier extends 
EventNotifierSupport {
     private String camelContextMatcher = ".*";
     private String routeMatcher = ".*";
     private DecanterCamelEventExtender extender = null;
+    private boolean includeProperties = true;
+    private boolean includeHeaders = true;
+    private boolean includeBody = true;
 
     public EventAdmin getEventAdmin() {
         return eventAdmin;
@@ -72,6 +75,14 @@ public class DecanterEventNotifier extends 
EventNotifierSupport {
         this.extender = extender;
     }
 
+    public void setIncludeHeaders(boolean includeHeaders) {
+        this.includeHeaders = includeHeaders;
+    }
+
+    public void setIncludeProperties(boolean includeProperties) {
+        this.includeProperties = includeProperties;
+    }
+
     @Override
     public boolean isEnabled(EventObject eventObject) {
         if (eventObject != null) {
@@ -297,14 +308,24 @@ public class DecanterEventNotifier extends 
EventNotifierSupport {
         data.put("camelContextName", exchange.getContext().getName());
         data.put("shortExchangeId", extractShortExchangeId(exchange));
         data.put("exchangePattern", exchange.getPattern().toString());
-        data.put("properties", exchange.getProperties());
-        data.put("inHeaders", exchange.getIn().getHeaders());
-        data.put("inBody", 
MessageHelper.extractBodyAsString(exchange.getIn()));
-        data.put("inBodyType", 
MessageHelper.getBodyTypeName(exchange.getIn()));
+        if (includeProperties) {
+            data.put("properties", exchange.getProperties());
+        }
+        if (includeHeaders) {
+            data.put("inHeaders", exchange.getIn().getHeaders());
+        }
+        if (includeBody) {
+            data.put("inBody", 
MessageHelper.extractBodyAsString(exchange.getIn()));
+            data.put("inBodyType", 
MessageHelper.getBodyTypeName(exchange.getIn()));
+        }
         if (exchange.hasOut()) {
-            data.put("outHeaders", exchange.getOut().getHeaders());
-            data.put("outBody", 
MessageHelper.extractBodyAsString(exchange.getOut()));
-            data.put("outBodyType", 
MessageHelper.getBodyTypeName(exchange.getOut()));
+            if (includeHeaders) {
+                data.put("outHeaders", exchange.getOut().getHeaders());
+            }
+            if (includeBody) {
+                data.put("outBody", 
MessageHelper.extractBodyAsString(exchange.getOut()));
+                data.put("outBodyType", 
MessageHelper.getBodyTypeName(exchange.getOut()));
+            }
         }
         data.put("causedByException", extractCausedByException(exchange));
         if (extender != null) {

http://git-wip-us.apache.org/repos/asf/karaf-decanter/blob/41cdd899/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterTraceEventHandler.java
----------------------------------------------------------------------
diff --git 
a/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterTraceEventHandler.java
 
b/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterTraceEventHandler.java
index a1602ee..c7d1b0e 100644
--- 
a/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterTraceEventHandler.java
+++ 
b/collector/camel/src/main/java/org/apache/karaf/decanter/collector/camel/DecanterTraceEventHandler.java
@@ -34,6 +34,9 @@ public class DecanterTraceEventHandler implements 
TraceEventHandler {
 
     private EventAdmin eventAdmin;
     private DecanterCamelEventExtender extender = null;
+    private boolean includeHeaders = true;
+    private boolean includeProperties = true;
+    private boolean includeBody = true;
 
     public DecanterTraceEventHandler() {
     }
@@ -50,6 +53,14 @@ public class DecanterTraceEventHandler implements 
TraceEventHandler {
         this.eventAdmin = eventAdmin;
     }
 
+    public void setIncludeHeaders(boolean includeHeaders) {
+        this.includeHeaders = includeHeaders;
+    }
+
+    public void setIncludeProperties(boolean includeProperties) {
+        this.includeProperties = includeProperties;
+    }
+
     @Override
     public void traceExchange(ProcessorDefinition<?> node, Processor target, 
TraceInterceptor traceInterceptor, Exchange exchange) throws Exception {
         HashMap<String, Object> data = new HashMap<>();
@@ -72,19 +83,29 @@ public class DecanterTraceEventHandler implements 
TraceEventHandler {
                 data.put(property.substring("decanter.".length()), 
exchange.getProperties().get(property));
             }
         }
-        data.put("properties", exchange.getProperties().isEmpty() ? null : 
exchange.getProperties());
+        if (includeProperties) {
+            data.put("properties", exchange.getProperties().isEmpty() ? null : 
exchange.getProperties());
+        }
         for (String header : exchange.getIn().getHeaders().keySet()) {
             if (header.startsWith("decanter.")) {
                 data.put(header.substring("decanter.".length()), 
exchange.getIn().getHeader(header));
             }
         }
-        data.put("inHeaders", exchange.getIn().getHeaders().isEmpty() ? null : 
exchange.getIn().getHeaders());
-        data.put("inBody", 
MessageHelper.extractBodyAsString(exchange.getIn()));
-        data.put("inBodyType", 
MessageHelper.getBodyTypeName(exchange.getIn()));
+        if (includeHeaders) {
+            data.put("inHeaders", exchange.getIn().getHeaders().isEmpty() ? 
null : exchange.getIn().getHeaders());
+        }
+        if (includeBody) {
+            data.put("inBody", 
MessageHelper.extractBodyAsString(exchange.getIn()));
+            data.put("inBodyType", 
MessageHelper.getBodyTypeName(exchange.getIn()));
+        }
         if (exchange.hasOut()) {
-            data.put("outHeaders", exchange.getOut().getHeaders().isEmpty() ? 
null : exchange.getOut().getHeaders());
-            data.put("outBody", 
MessageHelper.extractBodyAsString(exchange.getOut()));
-            data.put("outBodyType", 
MessageHelper.getBodyTypeName(exchange.getOut()));
+            if (includeHeaders) {
+                data.put("outHeaders", 
exchange.getOut().getHeaders().isEmpty() ? null : 
exchange.getOut().getHeaders());
+            }
+            if (includeBody) {
+                data.put("outBody", 
MessageHelper.extractBodyAsString(exchange.getOut()));
+                data.put("outBodyType", 
MessageHelper.getBodyTypeName(exchange.getOut()));
+            }
         }
         data.put("causedByException", extractCausedByException(exchange));
         if (extender != null) {

Reply via email to