I'm trying to get Appstats to work on my GAE Python app. I'm using webapp2 with python 2.7.
I've followed the instructions from https://developers.google.com/appengine/docs/python/tools/appstats#Setup which includes creating the appengine_config.py file:
def webapp_add_wsgi_middleware(app):
from google.appengine.ext.appstats import recording
app = recording.appstats_wsgi_middleware(app)
return app
And adding the following lines to my app.yaml:
builtins:
- appstats: on
The python app I wish to use Appstats on looks something like this:
import webapp2
from google.appengine.api import urlfetch
from google.appengine.ext import db
import appengine_config
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello word!')
app = webapp2.WSGIApplication([
webapp2.Route(r'/method1/', handler=Method1, name='method1'),
webapp2.Route(r'/method2/', handler=Method2, name='method2'),
webapp2.Route(r'/', handler=MainHandler, name='home')
], debug=True)
(I tried import appengine_config
after reading the comments from Appstats are only working for one WSGIApplication but that doesn't work neither)
The problem I'm facing is that I can see the appstats console at /_ah/stats
but it is not recording anything even after many requests have been made to the app.
I'm wondering if it has anything to do with the fact that I'm using extended URL routes? I'd really like to use webapps2 extended routing, so I hope Appstats doesn't have issues with it. If anyone has any insights on what I'm doing wrong, it will really help!
Thanks loads in advance!
Maybe this will help:
1) I only configured in my app.yaml:
2) And the appengine_config.py :
3) I did not have to change my handlers or routing.
After much investigation, it turned out that the answer to my problem was a careless mistake. I had somehow created the
appengine_config.py
file in a sub folder, rather than the root folder, and I didn't notice it because I had been using an IDE.So should anyone have this problem, make sure:
appengine_config.py
is in the root folderappengine_config.py
contains the code mentioned aboveapp.yaml
contains theappstats: on
as abuiltins:
(If you can access/_ah/stats
, this part is configured properly)And it should work. :)