code: def get_trace_id_from_webapp2():
      
      if webapp2 is None:
          return None
  
      try:
          # get_request() succeeds if we're in the middle of a webapp2
          # request, or raises an assertion error otherwise:
          # "Request global variable is not set".
          req = webapp2.get_request()
      except AssertionError:
          return None
  
      header = req.headers.get(_WEBAPP2_TRACE_HEADER)
  
      if header is None:
          return None
  
      trace_id = header.split("/", 1)[0]
  
      return trace_id
docs: Get trace_id from webapp2 request headers.
  
      :rtype: str
      :returns: TraceID in HTTP request headers.