You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/09/29 16:08:20 UTC
[skywalking] 01/01: Make the extension header really extendable
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch extension-header-fix
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 38c243355157db89ccf45a638af1e2ce09f845a9
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Sep 30 00:06:55 2020 +0800
Make the extension header really extendable
---
.../apm/agent/core/context/ExtensionContext.java | 24 +++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ExtensionContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ExtensionContext.java
index 8106fa6..e2564a8 100644
--- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ExtensionContext.java
+++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ExtensionContext.java
@@ -18,13 +18,13 @@
package org.apache.skywalking.apm.agent.core.context;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-
import java.util.Objects;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.util.StringUtil;
/**
- * Extension context, It provides the interaction capabilities between the agents
- * deployed in upstream and downstream services.
+ * Extension context, It provides the interaction capabilities between the agents deployed in upstream and downstream
+ * services.
*/
public class ExtensionContext {
@@ -46,7 +46,15 @@ public class ExtensionContext {
* Deserialize data from {@link String}
*/
void deserialize(String value) {
- this.skipAnalysis = Objects.equals(value, "1");
+ if (StringUtil.isEmpty(value)) {
+ return;
+ }
+ final String[] extensionParts = value.split("-");
+ // All parts of the extension header are optional.
+ // only try to read it when it exist.
+ if (extensionParts.length > 0) {
+ this.skipAnalysis = Objects.equals(extensionParts[0], "1");
+ }
}
/**
@@ -87,8 +95,10 @@ public class ExtensionContext {
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
ExtensionContext that = (ExtensionContext) o;
return skipAnalysis == that.skipAnalysis;
}