Anyone tried integrating gae-mini-profiler?

Skip to first unread message


Jun 27, 2011, 1:08:08 PM6/27/11
It's a new-fangled profiler that provides info similar to Appstats, but embedded into the live page.

I took a quick stab at getting it working with tipfy last night, but it appears to expect you to be using Django's templating system.


Jun 27, 2011, 3:24:29 PM6/27/11
I made some progress on this.  I got it working in a hello_world project, but it's not quite there on a more complicated project.

Drop the gae_mini_profiler folder into your tipfy app's folder, and add the following.

at the top of your app.yaml add:
- url: /gae_mini_profiler/static
  static_dir: gae_mini_profiler/static

- url: /gae_mini_profiler/.*
  script: gae_mini_profiler/

in your tipfy add:
def enable_gae_mini_profiler(app):
    """Enables gae_mini_profiler middleware."""

    from google.appengine.dist import use_library
    use_library('django', '1.2')

    from gae_mini_profiler import profiler
    if app.debug:
        app._debugged_wsgi_app = profiler.ProfilerWSGIMiddleware(app._debugged_wsgi_app)
        app.dispatch = profiler.ProfilerWSGIMiddleware(app.dispatch)

and where you'd normally add the enable_appstats(app) call add:

in your handler script add:
from gae_mini_profiler import profiler
from gae_mini_profiler.templatetags import profiler_includes_request_id

and in your get or post method and this to the template's context:
context['gae_mini_profiler'] = profiler_includes_request_id(profiler.request_id),

right before the closing body tag of your template add:
{{ gae_mini_profiler|safe }}

Then if the email address of the current user is in the gae_mini_profiler/ "enabled_profile_emails" list you should see the profile tab on your pages.


Jun 27, 2011, 4:24:07 PM6/27/11
I figured out what was going wrong in the other project.  I was using to control the frequency of Appstats running.  So only a tiny fraction of pageviews were working with gae_mini_profiler.

If you are using, you should add this to the top of your "appstats_should_record" method:
def appstats_should_record(env):
  from gae_mini_profiler.config import should_profile
  if should_profile(env):
    return True
So, gae_mini_profiler works great with tipfy.
Reply all
Reply to author
0 new messages