code: def generate_new_cid(upstream_cid=None):
      
      if upstream_cid is None:
          return str(uuid.uuid4()) if getattr(settings, 'CID_GENERATE', False) else None
      if (
              getattr(settings, 'CID_CONCATENATE_IDS', False)
              and getattr(settings, 'CID_GENERATE', False)
      ):
          return '%s, %s' % (upstream_cid, str(uuid.uuid4()))
      return upstream_cid
docs: Generate a new correlation id, possibly based on the given one.