@Test public void testEncodedValue() throws Exception { SofaTracerSpanContext spanContext = SofaTracerSpanContext.rootStart(); Map<String, String> baggage = new HashMap<>(); baggage.put("key", "value"); baggage.put("key1", "value1"); baggage.put("key2", "value2"); spanContext.addBizBaggage(baggage); final TextMap carrier = new TextMap() { Map<String, String> carr = new HashMap<>(); @Override public Iterator<Map.Entry<String, String>> iterator() { return carr.entrySet().iterator(); } @Override public void put(String key, String value) { carr.put(key, value); } @Override public String toString() { return "$classname{" + "carr=" + carr + '}'; } }; this.registryExtractorInjector.inject(spanContext, carrier); SofaTracerSpanContext extractContext = this.registryExtractorInjector.extract(carrier); extractContext.equals(spanContext); assertTrue("Extract baggage : " + extractContext.getBizBaggage(), baggage.equals(extractContext.getBizBaggage())); }
@Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } try { return URLEncoder.encode(value, SofaTracerConstant.DEFAULT_UTF8_ENCODING); } catch (UnsupportedEncodingException e) { return value; } }
HttpHeadersFormatter extends AbstractTextFormatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } try { return URLEncoder.encode(value, SofaTracerConstant.DEFAULT_UTF8_ENCODING); } catch (UnsupportedEncodingException e) { return value; } } }
HttpHeadersFormatter extends AbstractTextFormatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } try { return URLEncoder.encode(value, SofaTracerConstant.DEFAULT_UTF8_ENCODING); } catch (UnsupportedEncodingException e) { return value; } }  }
HttpHeadersFormatter extends AbstractTextFormatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } try { return URLEncoder.encode(value, SofaTracerConstant.DEFAULT_UTF8_ENCODING); } catch (UnsupportedEncodingException e) { return value; } }  @Override Format<TextMap> getFormatType(); }
HttpHeadersFormatter extends AbstractTextFormatter { @Override protected String encodedValue(String value) { if (StringUtils.isBlank(value)) { return StringUtils.EMPTY_STRING; } try { return URLEncoder.encode(value, SofaTracerConstant.DEFAULT_UTF8_ENCODING); } catch (UnsupportedEncodingException e) { return value; } }  @Override Format<TextMap> getFormatType();  }