@Test public void when_aHeaderIsGiven_then_aContextIsReturned() { assertEquals(X_RAY_TRACE_HEADER, ContextUtils.spanContextToHeader(context).toString()); }
public static TraceHeader spanContextToHeader(final SpanContext context) { String otTraceId = context.getTraceId().toLowerBase16(); String xrayTraceId = XRAY_VERSION_PREFIX + otTraceId.substring(0, 8) + XRAY_SEPARATOR + otTraceId.substring(8); TraceID xrayId = TraceID.fromString(xrayTraceId); TraceHeader header = new TraceHeader(); header.setSampled(context.getTraceFlags().isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED); header.setRootTraceId(xrayId); header.setParentId(context.getSpanId().toLowerBase16()); return header; }
ContextUtils { public static TraceHeader spanContextToHeader(final SpanContext context) { String otTraceId = context.getTraceId().toLowerBase16(); String xrayTraceId = XRAY_VERSION_PREFIX + otTraceId.substring(0, 8) + XRAY_SEPARATOR + otTraceId.substring(8); TraceID xrayId = TraceID.fromString(xrayTraceId); TraceHeader header = new TraceHeader(); header.setSampled(context.getTraceFlags().isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED); header.setRootTraceId(xrayId); header.setParentId(context.getSpanId().toLowerBase16()); return header; } }
ContextUtils { public static TraceHeader spanContextToHeader(final SpanContext context) { String otTraceId = context.getTraceId().toLowerBase16(); String xrayTraceId = XRAY_VERSION_PREFIX + otTraceId.substring(0, 8) + XRAY_SEPARATOR + otTraceId.substring(8); TraceID xrayId = TraceID.fromString(xrayTraceId); TraceHeader header = new TraceHeader(); header.setSampled(context.getTraceFlags().isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED); header.setRootTraceId(xrayId); header.setParentId(context.getSpanId().toLowerBase16()); return header; }  }
ContextUtils { public static TraceHeader spanContextToHeader(final SpanContext context) { String otTraceId = context.getTraceId().toLowerBase16(); String xrayTraceId = XRAY_VERSION_PREFIX + otTraceId.substring(0, 8) + XRAY_SEPARATOR + otTraceId.substring(8); TraceID xrayId = TraceID.fromString(xrayTraceId); TraceHeader header = new TraceHeader(); header.setSampled(context.getTraceFlags().isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED); header.setRootTraceId(xrayId); header.setParentId(context.getSpanId().toLowerBase16()); return header; }  static SpanContext entityToSpanContext(final Entity entity); static SpanContext headerToSpanContext(final TraceHeader header); static TraceHeader spanContextToHeader(final SpanContext context); }
ContextUtils { public static TraceHeader spanContextToHeader(final SpanContext context) { String otTraceId = context.getTraceId().toLowerBase16(); String xrayTraceId = XRAY_VERSION_PREFIX + otTraceId.substring(0, 8) + XRAY_SEPARATOR + otTraceId.substring(8); TraceID xrayId = TraceID.fromString(xrayTraceId); TraceHeader header = new TraceHeader(); header.setSampled(context.getTraceFlags().isSampled() ? TraceHeader.SampleDecision.SAMPLED : TraceHeader.SampleDecision.NOT_SAMPLED); header.setRootTraceId(xrayId); header.setParentId(context.getSpanId().toLowerBase16()); return header; }  static SpanContext entityToSpanContext(final Entity entity); static SpanContext headerToSpanContext(final TraceHeader header); static TraceHeader spanContextToHeader(final SpanContext context);  }