How do I get Appstats to work using Python 2.7 threadsafe and webapp2?

My application is using a streamed version of python 2.7 and I would like to use Appstats with it.

I am currently allowing the execution container to instantiate my application with webapp2.WSGIApplication()

and unfortunately none of my modules are loaded into Appstats.

However, if I follow these instructions I must use run_wsgi_app()

to call my application. From what I understand, using webapp2.WSGIApplication()

it provides several performance / application caching benefits.

How can I use Appstats with webapp2.WSGIApplication()

and maintain the performance benefits?


source to share

2 answers

This may be another manifestation of Appstats only work for one WSGIApplication (for which I already logged an internal error, but also showed it works).



I found that if I included appstates in app.yaml along with the creation of the file, it seems to me like it works with whatever I throw at it.


  - admin_redirect: on
  - appstats: on

def webapp_add_wsgi_middleware(app):
    from google.appengine.ext.appstats import recording
    app = recording.appstats_wsgi_middleware(app)
    return app




All Articles