Skip to main content

Handler mixins for automated metric reporting

Project description

The RequestMetricsMixin mixin will automatically instrument requests by sending statsd increment and timing values as each request finishes.

Version Downloads Status Coverage License

Deprecation Notice

This project has been replaced by sprockets-statsd and wil no longer be maintained. If you are currently using it, please migrate away from it.

Installation

sprockets.mixins.statsd is available on the Python Package Index and can be installed via pip or easy_install:

pip install sprockets.mixins.statsd

Documentation

https://sprocketsmixinsstatsd.readthedocs.org/

Requirements

Example

The following RequestHandler will automatically increment a request counter and add a request duration timing value to statsd when the request finishes.

from sprockets.mixins import statsd
from tornado import web

class MyRequestHandler(statsd.RequestMetricsMixin,
                       web.RequestHandler):

    def prepare(self):
        self.statsd_prefix = 'some.overriden.value'
        super(MyRequestHandler, self).prepare()

    def get(self, *args, **kwargs):
        self.finish({'hello': 'world'})

    def on_finish(self):
        super(MyRequestHandler, self).on_finish()
        self.do_cleanup_things()

When the request has finished, the following keys would be used:

  • Counter: sprockets.counter.example.RequestHandler.GET.200

  • Timing: sprockets.timers.example.RequestHandler.GET.200

Mixin Behavior

Whenever you mix in a class in Python always ensure that the mixins, which should inherit from object, are the first ones in the inheritance list. The concrete class, in this case web.RequestHandler should be the final class inherited.

Should your Request Handler extend the finish or the prepare methods ensure that your call super otherwise you may run into strange behavior.

Version History

Available at https://sprocketsmixinsstatsd.readthedocs.org/en/latest/history.html

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.statsd-1.4.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl (6.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sprockets.mixins.statsd-1.4.0.tar.gz.

File metadata

  • Download URL: sprockets.mixins.statsd-1.4.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for sprockets.mixins.statsd-1.4.0.tar.gz
Algorithm Hash digest
SHA256 6f3e81757524ff4cb740fdee2e204e657e34bd3ecadbb12653e00f5bbde9b5e0
MD5 7635df87f9d61e50f5030ac73c4b7e7a
BLAKE2b-256 35bd0e211dcf7ec48d7f8759e13dbfc93fc41d8a8e241c16fef6bdb01eb1d4e6

See more details on using hashes here.

File details

Details for the file sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10

File hashes

Hashes for sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e56dd5e2ef39709be35762870aab7bf251a1348fce42b7b04e531bc50ac17a05
MD5 7963c62bb2e4ca5859d68df739144103
BLAKE2b-256 e99b81e1c67ad4e8e765bce7e650bb30bd15ab5b67e30f928f3b54e6aaea2cc7

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