Skip to main content

Stuff to correlate requests, logs, and the like

Project description

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Sprockets nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Description: sprockets.mixins.correlation
============================

|Version| |Status| |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://img.shields.io/github/license/sprockets/sprockets.mixins.correlation.svg?
:target: https://sprocketsmixinscorrelation.readthedocs.io/
.. |Documentation| image:: https://readthedocs.org/projects/sprocketsmixinscorrelation/badge
:target: https://sprocketsmixinscorrelation.readthedocs.io/

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

Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sprockets.mixins.correlation-2.0.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

sprockets.mixins.correlation-2.0.0-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sprockets.mixins.correlation-2.0.0.tar.gz.

File metadata

  • Download URL: sprockets.mixins.correlation-2.0.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for sprockets.mixins.correlation-2.0.0.tar.gz
Algorithm Hash digest
SHA256 2a238aa08889434962405f6e6b7c7572f31433cc0de632360688e3b2a1d1e9c7
MD5 5973f7bf81060546923773089eaa9d9e
BLAKE2b-256 947b2d5a2a8cdae2a3cb648e4c944eeba9c1a9d9c3c7d0fad8245ad517790420

See more details on using hashes here.

File details

Details for the file sprockets.mixins.correlation-2.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: sprockets.mixins.correlation-2.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for sprockets.mixins.correlation-2.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ef97c3f413124e470bf4a85b03dc747c2bc3e017b50b62ffeb5a95ea625f37fd
MD5 0fbf2fbe332d34276db8b6682f78da15
BLAKE2b-256 6218a28b240f2714c77d1c016dcd48cff98a29842d851eb8abf529768216135c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page