code: def header_to_id(header):
      
      if not isinstance(header, string_types):
          return BAD_ID
  
      try:
          # Test that header is truly a hexadecimal value before we try to convert
          int(header, 16)
  
          length = len(header)
          if length < 16:
              # Left pad ID with zeros
              header = header.zfill(16)
          elif length > 16:
              # Phase 0: Discard everything but the last 16byte
              header = header[-16:]
  
          return header
      except ValueError:
          return BAD_ID
docs: We can receive headers in the following formats:
        1. unsigned base 16 hex string of variable length
        2. [eventual]
  
      :param header: the header to analyze, validate and convert (if needed)
      :return: a valid ID to be used internal to the tracer