Skip to main content

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

Release files for sprockets.mixins.statsd 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sprockets.mixins.statsd 1.4.0
File Size Uploaded
sprockets.mixins.statsd-1.4.0.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sprockets.mixins.statsd 1.4.0
File Interpreter ABI Platform
sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 11.2 kB

Release files / sprockets.mixins.statsd-1.4.0.tar.gz

Download URL sprockets.mixins.statsd-1.4.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6f3e81757524ff4cb740fdee2e204e657e34bd3ecadbb12653e00f5bbde9b5e0
BLAKE2b-256 checksum
How to use checksums
35bd0e211dcf7ec48d7f8759e13dbfc93fc41d8a8e241c16fef6bdb01eb1d4e6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl

Download URL sprockets.mixins.statsd-1.4.0-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e56dd5e2ef39709be35762870aab7bf251a1348fce42b7b04e531bc50ac17a05
BLAKE2b-256 checksum
How to use checksums
e99b81e1c67ad4e8e765bce7e650bb30bd15ab5b67e30f928f3b54e6aaea2cc7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page