@Test public void testSerializeSpanContext() throws Exception { SofaTracerSpanContext sofaTracerSpanContext1 = new SofaTracerSpanContext("traceId", "spanId", "parentId", false); String serialized = sofaTracerSpanContext1.serializeSpanContext(); SofaTracerSpanContext deserialized = SofaTracerSpanContext .deserializeFromString(serialized); assertEquals("traceId", deserialized.getTraceId()); assertEquals("spanId", deserialized.getSpanId()); assertEquals("parentId", deserialized.getParentId()); assertFalse(deserialized.isSampled()); }
public String serializeSpanContext() { StringBuilder serializedValue = new StringBuilder(); serializedValue.append(TRACE_ID_KET).append(StringUtils.EQUAL).append(traceId) .append(StringUtils.AND); serializedValue.append(SPAN_ID_KET).append(StringUtils.EQUAL).append(spanId) .append(StringUtils.AND); serializedValue.append(PARENT_SPAN_ID_KET).append(StringUtils.EQUAL).append(parentId) .append(StringUtils.AND); serializedValue.append(SAMPLE_KET).append(StringUtils.EQUAL).append(isSampled) .append(StringUtils.AND); if (this.sysBaggage.size() > 0) { serializedValue.append(StringUtils.mapToStringWithPrefix(this.sysBaggage, SYS_BAGGAGE_PREFIX_KEY)); } if (this.bizBaggage.size() > 0) { serializedValue.append(StringUtils.mapToString(bizBaggage)); } return serializedValue.toString(); }
SofaTracerSpanContext implements SpanContext { public String serializeSpanContext() { StringBuilder serializedValue = new StringBuilder(); serializedValue.append(TRACE_ID_KET).append(StringUtils.EQUAL).append(traceId) .append(StringUtils.AND); serializedValue.append(SPAN_ID_KET).append(StringUtils.EQUAL).append(spanId) .append(StringUtils.AND); serializedValue.append(PARENT_SPAN_ID_KET).append(StringUtils.EQUAL).append(parentId) .append(StringUtils.AND); serializedValue.append(SAMPLE_KET).append(StringUtils.EQUAL).append(isSampled) .append(StringUtils.AND); if (this.sysBaggage.size() > 0) { serializedValue.append(StringUtils.mapToStringWithPrefix(this.sysBaggage, SYS_BAGGAGE_PREFIX_KEY)); } if (this.bizBaggage.size() > 0) { serializedValue.append(StringUtils.mapToString(bizBaggage)); } return serializedValue.toString(); } }
SofaTracerSpanContext implements SpanContext { public String serializeSpanContext() { StringBuilder serializedValue = new StringBuilder(); serializedValue.append(TRACE_ID_KET).append(StringUtils.EQUAL).append(traceId) .append(StringUtils.AND); serializedValue.append(SPAN_ID_KET).append(StringUtils.EQUAL).append(spanId) .append(StringUtils.AND); serializedValue.append(PARENT_SPAN_ID_KET).append(StringUtils.EQUAL).append(parentId) .append(StringUtils.AND); serializedValue.append(SAMPLE_KET).append(StringUtils.EQUAL).append(isSampled) .append(StringUtils.AND); if (this.sysBaggage.size() > 0) { serializedValue.append(StringUtils.mapToStringWithPrefix(this.sysBaggage, SYS_BAGGAGE_PREFIX_KEY)); } if (this.bizBaggage.size() > 0) { serializedValue.append(StringUtils.mapToString(bizBaggage)); } return serializedValue.toString(); } SofaTracerSpanContext();  SofaTracerSpanContext(String traceId, String spanId);  SofaTracerSpanContext(String traceId, String spanId, String parentId);  SofaTracerSpanContext(String traceId, String spanId, String parentId, boolean isSampled); }
SofaTracerSpanContext implements SpanContext { public String serializeSpanContext() { StringBuilder serializedValue = new StringBuilder(); serializedValue.append(TRACE_ID_KET).append(StringUtils.EQUAL).append(traceId) .append(StringUtils.AND); serializedValue.append(SPAN_ID_KET).append(StringUtils.EQUAL).append(spanId) .append(StringUtils.AND); serializedValue.append(PARENT_SPAN_ID_KET).append(StringUtils.EQUAL).append(parentId) .append(StringUtils.AND); serializedValue.append(SAMPLE_KET).append(StringUtils.EQUAL).append(isSampled) .append(StringUtils.AND); if (this.sysBaggage.size() > 0) { serializedValue.append(StringUtils.mapToStringWithPrefix(this.sysBaggage, SYS_BAGGAGE_PREFIX_KEY)); } if (this.bizBaggage.size() > 0) { serializedValue.append(StringUtils.mapToString(bizBaggage)); } return serializedValue.toString(); } SofaTracerSpanContext();  SofaTracerSpanContext(String traceId, String spanId);  SofaTracerSpanContext(String traceId, String spanId, String parentId);  SofaTracerSpanContext(String traceId, String spanId, String parentId, boolean isSampled); SofaTracerSpanContext cloneInstance(); SofaTracerSpanContext addBizBaggage(Map<String, String> bizBaggage); SofaTracerSpanContext addSysBaggage(Map<String, String> sysBaggage); @Override Iterable<Map.Entry<String, String>> baggageItems(); String getBizSerializedBaggage(); String getSysSerializedBaggage(); void deserializeBizBaggage(String bizBaggageAttrs); void deserializeSysBaggage(String sysBaggageAttrs); String serializeSpanContext(); static SofaTracerSpanContext deserializeFromString(String deserializeValue); static SofaTracerSpanContext rootStart(); static SofaTracerSpanContext rootStart(boolean isSampled); void setTraceId(String traceId); void setSpanId(String spanId); SofaTracerSpanContext setBizBaggageItem(String key, String value); String getBizBaggageItem(String key); SofaTracerSpanContext setSysBaggageItem(String key, String value); String getSysBaggageItem(String key); String getTraceId(); String getSpanId(); String getParentId(); Map<String, String> getBizBaggage(); Map<String, String> getSysBaggage(); boolean isSampled(); void setSampled(boolean sampled); AtomicInteger getChildContextIndex(); String nextChildContextId(); String lastChildContextId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
SofaTracerSpanContext implements SpanContext { public String serializeSpanContext() { StringBuilder serializedValue = new StringBuilder(); serializedValue.append(TRACE_ID_KET).append(StringUtils.EQUAL).append(traceId) .append(StringUtils.AND); serializedValue.append(SPAN_ID_KET).append(StringUtils.EQUAL).append(spanId) .append(StringUtils.AND); serializedValue.append(PARENT_SPAN_ID_KET).append(StringUtils.EQUAL).append(parentId) .append(StringUtils.AND); serializedValue.append(SAMPLE_KET).append(StringUtils.EQUAL).append(isSampled) .append(StringUtils.AND); if (this.sysBaggage.size() > 0) { serializedValue.append(StringUtils.mapToStringWithPrefix(this.sysBaggage, SYS_BAGGAGE_PREFIX_KEY)); } if (this.bizBaggage.size() > 0) { serializedValue.append(StringUtils.mapToString(bizBaggage)); } return serializedValue.toString(); } SofaTracerSpanContext();  SofaTracerSpanContext(String traceId, String spanId);  SofaTracerSpanContext(String traceId, String spanId, String parentId);  SofaTracerSpanContext(String traceId, String spanId, String parentId, boolean isSampled); SofaTracerSpanContext cloneInstance(); SofaTracerSpanContext addBizBaggage(Map<String, String> bizBaggage); SofaTracerSpanContext addSysBaggage(Map<String, String> sysBaggage); @Override Iterable<Map.Entry<String, String>> baggageItems(); String getBizSerializedBaggage(); String getSysSerializedBaggage(); void deserializeBizBaggage(String bizBaggageAttrs); void deserializeSysBaggage(String sysBaggageAttrs); String serializeSpanContext(); static SofaTracerSpanContext deserializeFromString(String deserializeValue); static SofaTracerSpanContext rootStart(); static SofaTracerSpanContext rootStart(boolean isSampled); void setTraceId(String traceId); void setSpanId(String spanId); SofaTracerSpanContext setBizBaggageItem(String key, String value); String getBizBaggageItem(String key); SofaTracerSpanContext setSysBaggageItem(String key, String value); String getSysBaggageItem(String key); String getTraceId(); String getSpanId(); String getParentId(); Map<String, String> getBizBaggage(); Map<String, String> getSysBaggage(); boolean isSampled(); void setSampled(boolean sampled); AtomicInteger getChildContextIndex(); String nextChildContextId(); String lastChildContextId(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final String RPC_ID_SEPARATOR; }