Skip to content
Browse files

minor corrections

  • Loading branch information...
1 parent 398567e commit b87149503abae66244814436118b6b6d41ce2b6c @rhettg committed Mar 15, 2012
Showing with 35 additions and 1 deletion.
  1. +33 −0
  2. +1 −0 ziggy/
  3. +1 −1 ziggy/
@@ -75,6 +75,39 @@ For production use, you'll need to set the collection host and port:
ziggy.configure("", 3514)
+### Tornado Hooks
+Ziggy comes out of the box with support for Tornado web server. This is
+particularly challenging since one of the goals for ziggy is to, like the
+logging module, have globally accessible contexts so you don't have to pass
+anything around to have access to all the heirarchical goodness.
+Since you'll likely want to have a context per web request, it's difficult o
+work around tornado's async machinery to make that work well.
+Fear not, batteries included: `ziggy.tornado_utils`
+The most straightfoward way to integrate ziggy into a tornado application requires two things:
+ 1. Allow ziggy to monkey patch async tooling (tornado.gen primarily)
+ 1. Use or re-implement the provided base request handler `ziggy.tornado_utils.SampleRequestHandler`
+To install the monkey patching, add the line:
+ ziggy.tornado_utils.install()
+This must be executed BEFORE any of your RequestHandlers are imported.
+This is required if you are using @asynchronous and @gen.engine. If you are
+manually managing callbacks (which you probably shouldn't be), you'll need
+manually recall the ziggy context with `self.ziggy.start()`
+See `tests/` for an example of all this.
+If you have your own base request handlers you'll likely want to reimplement
+based on the one provided rather than trying to use inheritance. This will also
+make it really clear what you are including in your top-level event and allow
+you to name it whatever you want.
Event Collection
1 ziggy/
@@ -115,6 +115,7 @@ def stop(self):
def done(self):
+ self.stop() # Just be sure
if self.enabled and _recorder_function:
2 ziggy/
@@ -108,7 +108,7 @@ def finish(self):
return res
_execute = wrap_execute('request')(tornado.web.RequestHandler._execute)
- finish = wrap_finish(tornado.web.RequestHandler.finish)
+ finish = wrap_finish(finish)
# We need a custom version of this decorator so that we can pass in our ziggy

0 comments on commit b871495

Please sign in to comment.
Something went wrong with that request. Please try again.