class ContextUtils {

  public static SpanContext headerToSpanContext(final TraceHeader header) {
    TraceId traceId = TraceId
        .fromLowerBase16(xrayTraceIdToOT(header.getRootTraceId().toString()), 0);
    SpanId spanId = SpanId.fromLowerBase16(header.getParentId().toLowerCase(), 0);
    TraceFlags flags = TraceFlags.builder()
        .setIsSampled(header.getSampled().equals(TraceHeader.SampleDecision.SAMPLED)
            || header.getSampled().equals(TraceHeader.SampleDecision.REQUESTED))
        .build();
    Tracestate state = Tracestate.getDefault();
    return SpanContext.createFromRemoteParent(traceId, spanId, flags, state);
  }

}