code: private void putRequestIDs( HttpServletRequest hsr, ThreadContext threadContext, MDCManager mdcManager )
      {
          /* We would always generate internalID and provide that in the MDC.
           * If the calling service supplies an externalID, we'd map that under its own key.
           * PreferredID should try to use externalID if it's available, and default over to using internalID if it's not.
           * What this gives us is a single key we can use to reference an ID for the request,
           * and whenever possible it'll reflect the externally supplied ID.
           */
          String internalID = UUID.randomUUID().toString();
          String externalID = hsr.getHeader( EXTERNAL_ID );
          String preferredID = externalID != null ? externalID : internalID;
  
          mdcManager.putRequestIDs( internalID, externalID, preferredID );
  
          /*
           * We should also put the same values in the ThreadContext map, so we can reference them from code without
           * having to go through the logging framework
           */
          threadContext.put( INTERNAL_ID, internalID );
          if ( externalID != null )
          {
              threadContext.put( EXTERNAL_ID, externalID );
          }
          threadContext.put( PREFERRED_ID, preferredID );
      }
docs: Put to MDC / threadContext request IDs.