code: def _check_trace_id(self, trace_id):
          
          assert isinstance(trace_id, six.string_types)
  
          if trace_id is _INVALID_TRACE_ID:
              logging.warning(
                  'Trace_id {} is invalid (cannot be all zero), '
                  'generating a new one.'.format(trace_id))
              self.from_header = False
              return generate_trace_id()
  
          match = TRACE_ID_PATTERN.match(trace_id)
  
          if match:
              return trace_id
          else:
              logging.warning(
                  'Trace_id {} does not the match the required format,'
                  'generating a new one instead.'.format(trace_id))
              self.from_header = False
              return generate_trace_id()
docs: Check the format of the trace_id to ensure it is 32-character hex
          value representing a 128-bit number. If trace_id is invalid, returns a
          randomly generated trace id
  
          :type trace_id: str
          :param trace_id:
  
          :rtype: str
          :returns: Trace_id for the current context.