SofaTracerSpanContext implements SpanContext { public String getSysSerializedBaggage() { return StringUtils.mapToString(this.sysBaggage); } 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; }
@Test public void testGetSysSerializedBaggage() { SofaTracerSpanContext sofaTracerSpanContext = new SofaTracerSpanContext("traceId", "spanId", "parentId", false); Map<String, String> sysBaggage = new HashMap<String, String>(); sysBaggage.put("key", "value"); sysBaggage.put("key1", "value1"); sysBaggage.put("key2", "value2"); sysBaggage.put("key3", "value3"); sysBaggage.put("key4", "value4"); sofaTracerSpanContext.addSysBaggage(sysBaggage); String stringBaggage = sofaTracerSpanContext.getSysSerializedBaggage(); SofaTracerSpanContext sofaTracerSpanContext1 = new SofaTracerSpanContext("11", "11", "11", false); sofaTracerSpanContext1.deserializeSysBaggage(stringBaggage); assertEquals("\n" + stringBaggage, sysBaggage, sofaTracerSpanContext1.getSysBaggage()); }