@Test public void testDebugIdWithoutTraceHeader() { Map<String, String> extractCarrier = new HashMap<>(); TextMapAdapter textMap = new TextMapAdapter(extractCarrier); textMap.put(Constants.DEBUG_ID_HEADER_KEY, EXAMPLE_DEBUG_ID); JaegerSpanContext spanContext = traceContextCodec.extract(textMap); JaegerTracer tracer = new JaegerTracer.Builder("service").withReporter(new InMemoryReporter()).build(); JaegerSpan child = tracer.buildSpan("span").asChildOf(spanContext).start(); assertTrue(child.context().isDebug()); child.finish(); tracer.close(); }
@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);  }