Anyone tried integrating gae-mini-profiler?

165 views
Skip to first unread message

Calvin

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

https://github.com/kamens/gae_mini_profiler

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.

Calvin

unread,
Jun 27, 2011, 3:24:29 PM6/27/11
to ti...@googlegroups.com
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/main.py

in your tipfy main.py 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)
    else:
        app.dispatch = profiler.ProfilerWSGIMiddleware(app.dispatch)

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


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 }}
</body>

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

Calvin

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

If you are using appengine_config.py, 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
Forward
0 new messages