TextMapB3Formatter extends AbstractTextB3Formatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } return value; }  @Override Format<TextMap> getFormatType();  }
@Test public void testEncodedValue() throws Exception { SofaTracerSpanContext spanContext = SofaTracerSpanContext.rootStart(); Map<String, String> baggage = new ConcurrentHashMap<String, String>(); baggage.put("key", "value"); baggage.put("key1", "value1"); baggage.put("key2", "value2"); spanContext.addBizBaggage(baggage); Carrier4Test carrier = new Carrier4Test(); this.registryExtractorInjector.inject(spanContext, carrier); assertEquals(spanContext.getTraceId(), carrier.get(AbstractTextB3Formatter.TRACE_ID_KEY_HEAD)); assertEquals(spanContext.getSpanId(), carrier.get(AbstractTextB3Formatter.SPAN_ID_KEY_HEAD)); assertEquals(spanContext.getParentId(), carrier.get(AbstractTextB3Formatter.PARENT_SPAN_ID_KEY_HEAD)); SofaTracerSpanContext extractContext = this.registryExtractorInjector.extract(carrier); assertTrue(extractContext.equals(spanContext)); Map<String, String> baggageInContext = extractContext.getBizBaggage(); assertEquals(baggage.size(), baggageInContext.size()); assertEquals(baggage.get("key"), baggageInContext.get("key")); assertEquals(baggage.get("key1"), baggageInContext.get("key1")); assertEquals(baggage.get("key2"), baggageInContext.get("key2")); }