This sprocket provides a single mix-in that imbues your RequestHandler
with a unique correlation ID. If a correlation ID is present upon input then
it will be preserved in the output. It is also available for your use as
the correlation_id property.
Installation
sprockets.mixins.correlation is available on the Python Package Index
and can be installed via pip:
$pipinstallsprockets.mixins.correlation
Example
fromsprockets.mixinsimportcorrelationfromtornadoimportioloop,webclassHandler(correlation.HandlerMixin,web.RequestHandler):defget(self):self.finish('my id is {0}'.format(self.correlation_id)if__name__=='__main__':application=web.Application([('/',Handler)])application.listen(8888)ioloop.IOLoop.instance().start()
HTTP/1.1200OKCorrelation-ID:4676922073c4c59b1f5e6b4a18894bd46f867316Connection:closeContent-Length:48
my id is 4676922073c4c59b1f5e6b4a18894bd46f867316