class OtTracerPropagator implements TextMapPropagator {

  @Override
  public <C> Context extract(Context context, C carrier, Getter<C> getter) {
    if (context == null || getter == null) {
      return context;
    }
    String incomingTraceId = getter.get(carrier, TRACE_ID_HEADER);
    String traceId =
        incomingTraceId == null
            ? TraceId.getInvalid()
            : StringUtils.padLeft(incomingTraceId, MAX_TRACE_ID_LENGTH);
    String spanId = getter.get(carrier, SPAN_ID_HEADER);
    String sampled = getter.get(carrier, SAMPLED_HEADER);
    SpanContext spanContext = buildSpanContext(traceId, spanId, sampled);
    if (!spanContext.isValid()) {
      return context;
    }
    return TracingContextUtils.withSpan(DefaultSpan.create(spanContext), context);
  }

  private  OtTracerPropagator();

}