TracerUtils { public static boolean checkBaggageLength(SofaTracerSpan sofaTracerSpan, String key, String value) { int length = sofaTracerSpan.getSofaTracerSpanContext().getBizSerializedBaggage().length(); if (sofaTracerSpan.getBaggageItem(key) == null) { length += key.length() + value.length(); } else { length += value.length() - sofaTracerSpan.getBaggageItem(key).length(); } length = length + StringUtils.AND.length() + StringUtils.EQUAL.length(); return length <= getBaggageMaxLength(); }  static String getTraceId(); static boolean checkBaggageLength(SofaTracerSpan sofaTracerSpan, String key, String value); static int getSysBaggageMaxLength(); static int getBaggageMaxLength(); static String getPID(); static LogReserveConfig parseLogReserveConfig(String logReserveConfig); static boolean isLoadTest(SofaTracerSpan sofaTracerSpan); static String getLoadTestMark(SofaTracerSpan span); static String getInetAddress(); static String removeJSessionIdFromUrl(String url); static String getCurrentZone(); static String getDefaultTimeZone(); static String getEmptyStringIfNull(Map<String, String> map, String key); static String hostToHexString(String host); static final String KEY_OF_CURRENT_ZONE; static final String CURRENT_ZONE; static String P_ID_CACHE; }
@Test public void testCheckBaggageLength() { SofaTracer sofaTracer = mock(SofaTracer.class); SofaTracerSpanContext sofaTracerSpanContext = new SofaTracerSpanContext(); SofaTracerSpan sofaTracerSpan = new SofaTracerSpan(sofaTracer, System.currentTimeMillis(), "mock", sofaTracerSpanContext, new HashMap<>()); assertTrue(TracerUtils.checkBaggageLength(sofaTracerSpan, "key", "value")); }