You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/03/16 07:05:12 UTC

[incubator-skywalking] 01/01: Add namespace for headers.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch sw3_namespace
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git

commit caf48b62b721dbcd088420ace21ce8a05c5bb1ed
Author: wu-sheng <wu...@foxmail.com>
AuthorDate: Fri Mar 16 15:04:41 2018 +0800

    Add namespace for headers.
---
 .../org/apache/skywalking/apm/agent/core/conf/Config.java  |  5 +++++
 .../skywalking/apm/agent/core/context/CarrierItem.java     | 14 +++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
index 86fbebb..577a573 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
@@ -32,6 +32,11 @@ public class Config {
 
     public static class Agent {
         /**
+         * Namespace isolates headers in cross process propagation. The HEADER name will be `HeaderName:Namespace`.
+         */
+        public static String NAMESPACE = "";
+
+        /**
          * Application code is showed in sky-walking-ui. Suggestion: set an unique name for each application, one
          * application's nodes share the same code.
          */
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/CarrierItem.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/CarrierItem.java
index c5c343f..8038507 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/CarrierItem.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/CarrierItem.java
@@ -16,10 +16,12 @@
  *
  */
 
-
 package org.apache.skywalking.apm.agent.core.context;
 
 import java.util.Iterator;
+import org.apache.skywalking.apm.util.StringUtil;
+
+import static org.apache.skywalking.apm.agent.core.conf.Config.Agent.NAMESPACE;
 
 /**
  * @author wusheng
@@ -30,13 +32,15 @@ public class CarrierItem implements Iterator<CarrierItem> {
     private CarrierItem next;
 
     public CarrierItem(String headKey, String headValue) {
-        this.headKey = headKey;
-        this.headValue = headValue;
-        next = null;
+        this(headKey, headValue, null);
     }
 
     public CarrierItem(String headKey, String headValue, CarrierItem next) {
-        this.headKey = headKey;
+        if (StringUtil.isEmpty(NAMESPACE)) {
+            this.headKey = headKey;
+        } else {
+            this.headKey = NAMESPACE + ":" + headValue;
+        }
         this.headValue = headValue;
         this.next = next;
     }

-- 
To stop receiving notification emails like this one, please contact
wusheng@apache.org.