Here is a piece of code I've written which I thought may be useful to some other people...

You'll find here a simple python module to use with the Google AppEngine SDK to monkey patch the datastore API in order to get an idea of the calls performed by your application.

To instrument of the datastore, put at the top level of your handler file

import instrdatastore

Note that it's important to have this before any other import in your application or in the google package to avoid that some modules will use the unpatched version of datastore functions (and hence calls to those functions wouldn't be considered).

Then add at the end of your handler function


The handler file should look like this:

"""my handler file with datastore instrumenting activated"""
import instrdatastore

# ... other initialization code

# main function so this handler module is cached
def main():
  from wsgiref.handlers import CGIHandler
  from ginco.wsgi.handler import ErudiWSGIApplication
  application = ErudiWSGIApplication(config, vreg=vreg)

if __name__ == "__main__":

Now you should see in your logs the number of Get/Put/Delete/Query which has been done during request processing

2008-06-23 06:59:12 - (root) WARNING: datastore access information
2008-06-23 06:59:12 - (root) WARNING: nb Get: 2
2008-06-23 06:59:12 - (root) WARNING: arguments (args, kwargs):
((datastore_types.Key.from_path('EGroup', u'key_users', _app=u'winecellar'),), {})
((datastore_types.Key.from_path('EUser', u'', _app=u'winecellar'),), {})
2008-06-23 06:59:12 - (root) WARNING: nb Query: 1
2008-06-23 06:59:12 - (root) WARNING: arguments (args, kwargs):
(({'for_user =': None}, 'EProperty'), {})
2008-06-23 06:59:58 - (root) WARNING: nb Put: 1
2008-06-23 06:59:58 - (root) WARNING: arguments (args, kwargs):
(({u'login': None, u'last_usage_time': 1214204398.2022741, u'data': ""},), {})

I'll probably extend this as the time goes. Also notice you may encounter some problems with the automatic reloading feature of the dev app server when instrumentation is activated, in which case you should simply restart the web server.

blog entry of