How to disable appstats on handlers /_ah

App stats are an awesome tool if we want to know what’s happening every moment in our system.

They are very useful to detect errors, bottlenecks, and see where we can improve performance through asynchronous calls.

In some cases we can see in our system some warning logs that have nothing to do with our handlers and are derived from appstats problems.

Moreover, if we enable the global appstats throughout our system, also recorded statistics for system handlers, usually starting with / _ah /.

This can be awkward and It can make you review some warnings logs that are not direct problem of your code, and require more performance to manage statistics probably you never want to see.

There are two methods to disable appstats.

On the one hand, you can disable the statistics of your new handlers once you end debug process as follows:

from google.appengine.ext.appstats import recording

class MyHandlerClass(webapp2.RequestHandler):
  def get(self):
    # Disable appstats.
    recording.dont_record()

    # Do other tasks.

On the other hand, if you just want to disable appstats on system handlers / _ah / you need a configuration file for your application. You must create the file appengine_config.py and must contain the following:

appstats_FILTER_LIST = [{ 'PATH_INFO': '!/_ah/*' }]

Thus, any handler that matches the regular expression / _ah / * will be skipped in the App stats recording. The character “!” in front of the expression indicates that these handlers do not want to see in your log.


 Google+

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s