Created
May 24, 2013 04:20
-
-
Save jvanasco/5641263 to your computer and use it in GitHub Desktop.
Revisions
-
jvanasco created this gist
May 24, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ config.add_subscriber(\ "app.subscribers.statsd_timing", "pyramid.events.ContextFound") This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ def _statsd_timing_callback(request): timer_diff = int((time.time() - request.timing_ContextFound) * 1000) key = 'routes.%s' % request.matched_route.name key = key.replace(':','_') utils.statsd_client.timing( key , timer_diff ) utils.statsd_client.incr( key ) def statsd_timing(event): event.request.timing_ContextFound = time.time() event.request.add_finished_callback(_statsd_timing_callback) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ import statsd ## https://pypi.python.org/pypi/statsd/2.0.1 statsd_client = statsd.StatsClient('localhost',8125,prefix="pyramid")