Stuff to correlate requests, logs, and the like.
Find a file
2015-03-28 13:22:37 -04:00
docs Add documentation. 2015-03-28 13:04:21 -04:00
sprockets Add mixins.HandlerMixin. 2015-03-28 13:02:59 -04:00
.gitignore SYN 2015-03-28 12:35:38 -04:00
.travis.yml Fix travis-ci syntax. 2015-03-28 13:22:37 -04:00
dev-requirements.txt SYN 2015-03-28 12:35:38 -04:00
HISTORY.rst Add mixins.HandlerMixin. 2015-03-28 13:02:59 -04:00
LICENSE SYN 2015-03-28 12:35:38 -04:00
MANIFEST.in SYN 2015-03-28 12:35:38 -04:00
README.rst SYN 2015-03-28 12:35:38 -04:00
requirements.txt SYN 2015-03-28 12:35:38 -04:00
setup.cfg SYN 2015-03-28 12:35:38 -04:00
setup.py SYN 2015-03-28 12:35:38 -04:00
test-requirements.txt SYN 2015-03-28 12:35:38 -04:00
tests.py Add mixins.HandlerMixin. 2015-03-28 13:02:59 -04:00
tox.ini Add testing against various Tornado versions. 2015-03-28 13:04:42 -04:00

sprockets.mixins.correlation
============================

|Version| |Downloads| |Status| |Coverage| |License| |Documentation|

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``:

.. code-block:: shell

   $ pip install sprockets.mixins.correlation

Example
-------

.. code-block:: python

   from sprockets.mixins import correlation
   from tornado import ioloop, web

   class Handler(correlation.HandlerMixin, web.RequestHandler):
      def get(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()

Generated Correlation ID
~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: http

   GET / HTTP/1.1
   Host: localhost:8888
   Connection: keep-alive

.. code-block:: http

   HTTP/1.1 200 OK
   Correlation-ID: 0a2b6080-e4da-43bf-a2a5-38d861846cb9
   Content-Length: 44

   my id is 0a2b6080-e4da-43bf-a2a5-38d861846cb9

Relayed Correlation ID
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: http

   GET / HTTP/1.1
   Host: localhost:8888
   Connection: keep-alive
   Correlation-Id: 4676922073c4c59b1f5e6b4a18894bd46f867316

.. code-block:: http

   HTTP/1.1 200 OK
   Correlation-ID: 4676922073c4c59b1f5e6b4a18894bd46f867316
   Connection: close
   Content-Length: 48

   my id is 4676922073c4c59b1f5e6b4a18894bd46f867316


.. |Version| image:: https://img.shields.io/pypi/v/sprockets.mixins.correlation.svg
   :target: https://pypi.python.org/pypi/sprockets.mixins.correlation
.. |Status| image:: https://img.shields.io/travis/sprockets/sprockets.mixins.correlation.svg
   :target: https://travis-ci.org/sprockets/sprockets.mixins.correlation
.. |Coverage| image:: https://img.shields.io/coveralls/sprockets/sprockets.mixins.correlation.svg
   :target: http://coveralls.io/r/sprockets/sprockets.mixins.correlation
.. |Downloads| image:: https://img.shields.io/pypi/dm/sprockets.mixins.correlation.svg
   :target: https://pypi.python.org/pypi/sprockets.mixins.correlation
.. |License| image:: https://pypip.in/license/sprockets.mixins.correlation/badge.svg
   :target: https://sprocketsmixinscorrelation.readthedocs.org/
.. |Documentation| image:: https://readthedocs.org/projects/sprocketsmixinscorrelation/badge
   :target: https://sprocketsmixinscorrelation.readthedocs.org/

.. _Python Package Index: https://pypi.python.org/pypi/sprockets.mixins.correlation