SegmentDeserialize provides single segment json string deserialize and segment array file
@@ -13,17 +16,21 @@ import java.io.IOException;
public enum SegmentDeserialize {
INSTANCE;
- private final Gson gson = new Gson();
+ private final Logger logger = LogManager.getFormatterLogger(SegmentDeserialize.class);
/**
- * Single segment json string deserialize.
+ * Segment object binary value as a base64 encoded string deserialize.
*
- * @param singleSegmentJsonStr a segment json string
- * @return an {@link Segment}
- * @throws IOException if json string illegal or file broken.
+ * @param segmentObjBlob , to be a binary value as a base64 encoded string
+ * @return an {@link TraceSegmentObject}
*/
- public Segment deserializeSingle(String singleSegmentJsonStr) throws IOException {
- Segment segment = gson.fromJson(singleSegmentJsonStr, Segment.class);
- return segment;
+ public TraceSegmentObject deserializeSingle(String segmentObjBlob) {
+ try {
+ byte[] decode = Base64.decode(segmentObjBlob);
+ return TraceSegmentObject.parseFrom(decode);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
}
}
diff --git a/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Span.java b/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Span.java
deleted file mode 100644
index 716ee2fdf..000000000
--- a/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/entity/Span.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.skywalking.apm.collector.worker.segment.entity;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author pengys5
- */
-public class Span {
-
- @SerializedName("si")
- private int spanId;
-
- @SerializedName("ps")
- private int parentSpanId;
-
- @SerializedName("st")
- private long startTime;
-
- @SerializedName("et")
- private long endTime;
-
- @SerializedName("on")
- private String operationName;
-
- @SerializedName("ts")
- private Map
- * Created by wusheng on 2017/2/17.
- */
-public class BooleanTag extends AbstractTag
- * Created by wusheng on 2017/2/18.
- */
-public class IntTag extends AbstractTag
- * Created by wusheng on 2017/2/17.
- */
-public class ShortTag extends AbstractTag
- * Created by wusheng on 2017/2/17.
- */
-public class StringTag extends AbstractTag
- * Created by wusheng on 2017/2/17.
- */
-public final class Tags {
- private Tags() {
- }
-
- /**
- * URL records the url of the incoming request.
- */
- public static final StringTag URL = new StringTag("url");
-
- /**
- * STATUS_CODE records the http status code of the response.
- */
- public static final IntTag STATUS_CODE = new IntTag("status_code");
-
- /**
- * SPAN_KIND hints at the relationship between spans, e.g. client/server.
- */
- public static final StringTag SPAN_KIND = new StringTag("span.kind");
-
- /**
- * A constant for setting the span kind to indicate that it represents a server span.
- */
- public static final String SPAN_KIND_SERVER = "server";
-
- /**
- * A constant for setting the span kind to indicate that it represents a client span.
- */
- public static final String SPAN_KIND_CLIENT = "client";
-
- /**
- * SPAN_LAYER represents the kind of span.
- *
- * e.g.
- * db=database;
- * rpc=Remote Procedure Call Framework, like motan, thift;
- * nosql=something like redis/memcache
- */
- public static final class SPAN_LAYER {
- private static StringTag SPAN_LAYER_TAG = new StringTag("span.layer");
-
- public static String get(Span span) {
- return SPAN_LAYER_TAG.get(span);
- }
- }
-
- /**
- * COMPONENT is a low-cardinality identifier of the module, library, or package that is instrumented.
- * Like dubbo/dubbox/motan
- */
- public static final StringTag COMPONENT = new StringTag("component");
-
- /**
- * ERROR indicates whether a Span ended in an error state.
- */
- public static final BooleanTag ERROR = new BooleanTag("error", false);
-
- /**
- * PEER_HOST records host address (ip:port, or ip1:port1,ip2:port2) of the peer, maybe IPV4, IPV6 or hostname.
- */
- public static final StringTag PEER_HOST = new StringTag("peer.host");
-
- /**
- * PEER_PORT records remote port of the peer
- */
- public static final IntTag PEER_PORT = new IntTag("peer.port");
-
- /**
- * PEERS records multiple host address and port of remote
- */
- public static final StringTag PEERS = new StringTag("peers");
-
- /**
- * DB_TYPE records database type, such as sql, redis, cassandra and so on.
- */
- public static final StringTag DB_TYPE = new StringTag("db.type");
-
- /**
- * DB_INSTANCE records database instance name.
- */
- public static final StringTag DB_INSTANCE = new StringTag("db.instance");
-
- /**
- * DB_STATEMENT records the sql statement of the database access.
- */
- public static final StringTag DB_STATEMENT = new StringTag("db.statement");
-}
diff --git a/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java b/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java
index ba94bab86..a74072fed 100644
--- a/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java
+++ b/apm-collector/apm-collector-worker/src/main/java/org/skywalking/apm/collector/worker/segment/persistence/SegmentSave.java
@@ -1,5 +1,6 @@
package org.skywalking.apm.collector.worker.segment.persistence;
+import com.google.gson.JsonObject;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -13,7 +14,7 @@ import org.skywalking.apm.collector.actor.selector.WorkerSelector;
import org.skywalking.apm.collector.worker.PersistenceMember;
import org.skywalking.apm.collector.worker.config.CacheSizeConfig;
import org.skywalking.apm.collector.worker.segment.SegmentIndex;
-import org.skywalking.apm.collector.worker.segment.entity.SegmentAndJson;
+import org.skywalking.apm.collector.worker.segment.entity.SegmentAndBase64;
import org.skywalking.apm.collector.worker.storage.AbstractIndex;
import org.skywalking.apm.collector.worker.storage.EsClient;
import org.skywalking.apm.collector.worker.storage.PersistenceWorkerListener;
@@ -46,11 +47,11 @@ public class SegmentSave extends PersistenceMember