@Test public void support128BitTraceIdExtraction() { String hex128Bits = "463ac35c9f6413ad48485a3953bb6124"; String parentSpan = "d1595c6ec91668af"; String tracecontext = String.format("00-%s-%s-01", hex128Bits, parentSpan); TextMapAdapter textMap = new TextMapAdapter(new HashMap<>()); textMap.put(TRACE_PARENT, tracecontext); JaegerSpanContext context = traceContextCodec.extract(textMap); assertNotNull(HexCodec.lowerHexToUnsignedLong(parentSpan)); assertEquals(HexCodec.lowerHexToUnsignedLong(hex128Bits).longValue(), context.getTraceIdLow()); assertEquals(HexCodec.higherHexToUnsignedLong(hex128Bits).longValue(), context.getTraceIdHigh()); assertEquals(HexCodec.lowerHexToUnsignedLong(parentSpan).longValue(), context.getSpanId()); assertTrue(context.isSampled()); }
@Override public JaegerSpanContext extract(TextMap carrier) { String traceParent = null; String traceState = null; String debugId = null; for (Map.Entry<String, String> entry: carrier) { if (TRACE_PARENT.equalsIgnoreCase(entry.getKey())) { traceParent = entry.getValue(); } if (TRACE_STATE.equalsIgnoreCase(entry.getKey())) { traceState = entry.getValue(); } if (Constants.DEBUG_ID_HEADER_KEY.equalsIgnoreCase(entry.getKey())) { debugId = entry.getValue(); } } if (traceParent == null) { if (debugId != null) { return objectFactory.createSpanContext(0L, 0L, 0L, 0L, (byte) 0, null, debugId); } return null; } return extractContextFromTraceParent(traceParent, traceState, debugId); }
TraceContextCodec implements Codec<TextMap> { @Override public JaegerSpanContext extract(TextMap carrier) { String traceParent = null; String traceState = null; String debugId = null; for (Map.Entry<String, String> entry: carrier) { if (TRACE_PARENT.equalsIgnoreCase(entry.getKey())) { traceParent = entry.getValue(); } if (TRACE_STATE.equalsIgnoreCase(entry.getKey())) { traceState = entry.getValue(); } if (Constants.DEBUG_ID_HEADER_KEY.equalsIgnoreCase(entry.getKey())) { debugId = entry.getValue(); } } if (traceParent == null) { if (debugId != null) { return objectFactory.createSpanContext(0L, 0L, 0L, 0L, (byte) 0, null, debugId); } return null; } return extractContextFromTraceParent(traceParent, traceState, debugId); } }
TraceContextCodec implements Codec<TextMap> { @Override public JaegerSpanContext extract(TextMap carrier) { String traceParent = null; String traceState = null; String debugId = null; for (Map.Entry<String, String> entry: carrier) { if (TRACE_PARENT.equalsIgnoreCase(entry.getKey())) { traceParent = entry.getValue(); } if (TRACE_STATE.equalsIgnoreCase(entry.getKey())) { traceState = entry.getValue(); } if (Constants.DEBUG_ID_HEADER_KEY.equalsIgnoreCase(entry.getKey())) { debugId = entry.getValue(); } } if (traceParent == null) { if (debugId != null) { return objectFactory.createSpanContext(0L, 0L, 0L, 0L, (byte) 0, null, debugId); } return null; } return extractContextFromTraceParent(traceParent, traceState, debugId); } private  TraceContextCodec(Builder builder); }
TraceContextCodec implements Codec<TextMap> { @Override public JaegerSpanContext extract(TextMap carrier) { String traceParent = null; String traceState = null; String debugId = null; for (Map.Entry<String, String> entry: carrier) { if (TRACE_PARENT.equalsIgnoreCase(entry.getKey())) { traceParent = entry.getValue(); } if (TRACE_STATE.equalsIgnoreCase(entry.getKey())) { traceState = entry.getValue(); } if (Constants.DEBUG_ID_HEADER_KEY.equalsIgnoreCase(entry.getKey())) { debugId = entry.getValue(); } } if (traceParent == null) { if (debugId != null) { return objectFactory.createSpanContext(0L, 0L, 0L, 0L, (byte) 0, null, debugId); } return null; } return extractContextFromTraceParent(traceParent, traceState, debugId); } private  TraceContextCodec(Builder builder); @Override JaegerSpanContext extract(TextMap carrier); @Override void inject(JaegerSpanContext spanContext, TextMap carrier); }
TraceContextCodec implements Codec<TextMap> { @Override public JaegerSpanContext extract(TextMap carrier) { String traceParent = null; String traceState = null; String debugId = null; for (Map.Entry<String, String> entry: carrier) { if (TRACE_PARENT.equalsIgnoreCase(entry.getKey())) { traceParent = entry.getValue(); } if (TRACE_STATE.equalsIgnoreCase(entry.getKey())) { traceState = entry.getValue(); } if (Constants.DEBUG_ID_HEADER_KEY.equalsIgnoreCase(entry.getKey())) { debugId = entry.getValue(); } } if (traceParent == null) { if (debugId != null) { return objectFactory.createSpanContext(0L, 0L, 0L, 0L, (byte) 0, null, debugId); } return null; } return extractContextFromTraceParent(traceParent, traceState, debugId); } private  TraceContextCodec(Builder builder); @Override JaegerSpanContext extract(TextMap carrier); @Override void inject(JaegerSpanContext spanContext, TextMap carrier);  }