code: private SpanContext extract(HttpRequest request) {
      SpanContext spanContext = tracer.extract(Format.Builtin.HTTP_HEADERS,
          new HttpTextMapExtractAdapter(request));
  
      if (spanContext != null) {
        return spanContext;
      }
  
      Span span = tracer.activeSpan();
      if (span != null) {
        return span.context();
      }
  
      return null;
    }
docs: Extract context from headers or from active Span
  
  @param request http request
  @return extracted context