def webapp_add_wsgi_middleware(app):
 from google.appengine.ext.appstats import recording
 def save(self):
  t0 = time.time()
  with self._lock:
   num_pending = len(self.pending)
  if num_pending:
   logging.warn('Found %d RPC request(s) without matching response (presumably due to timeouts or other errors)', num_pending)
  self.dump()
  try:
   (key, len_part, len_full) = self._save()
  except Exception:
   logging.exception('Recorder.save() failed')
   return
  t1 = time.time()
  link = ('http://%s%s/details?time=%s' % (self.env.get('HTTP_HOST', ''), recording.config.stats_url, int((self.start_timestamp * 1000))))
  logging.debug('Saved; key: %s, part: %s bytes, full: %s bytes, overhead: %.3f + %.3f; link: %s', key, len_part, len_full, self.overhead, (t1 - t0), link)
 recording.Recorder.save = save
 app = recording.appstats_wsgi_middleware(app)
 return app

def webapp_add_wsgi_middleware ( app ) : from google . appengine . ext . appstats import recording def save ( self ) : t0 = time . time ( ) with self . _lock : num_pending = len ( self . pending ) if num_pending : logging . warn ( 'Found %d RPC request(s) without matching response (presumably due to timeouts or other errors)' , num_pending ) self . dump ( ) try : ( key , len_part , len_full ) = self . _save ( ) except Exception : logging . exception ( 'Recorder.save() failed' ) return t1 = time . time ( ) link = ( 'http://%s%s/details?time=%s' % ( self . env . get ( 'HTTP_HOST' , '' ) , recording . config . stats_url , int ( ( self . start_timestamp * 1000 ) ) ) ) logging . debug ( 'Saved; key: %s, part: %s bytes, full: %s bytes, overhead: %.3f + %.3f; link: %s' , key , len_part , len_full , self . overhead , ( t1 - t0 ) , link ) recording . Recorder . save = save app = recording . appstats_wsgi_middleware ( app ) return app
applying the i18nmiddleware to our helloworld app .