Django Statsd Client¶
Contents:
Introduction¶
django_statsd is a middleware that uses python-statsd to log query and view durations to statsd.
- Documentation
- Bug reports
- Package homepage
- Python Statsd
- Graphite
Install¶
To install simply execute python setup.py install. If you want to run the tests first, run python setup.py test
Usage¶
To install, add the following to your settings.py
:
django_statsd
to theINSTALLED_APPS
setting.django_statsd.middleware.StatsdMiddleware
to the top of yourMIDDLEWARE_CLASSES
django_statsd.middleware.StatsdMiddlewareTimer
to the bottom of yourMIDDLEWARE_CLASSES
Advanced Usage¶
>>> def some_view(request):
... with request.timings('something_to_time'):
... # do something here
... pass
>>>
>>> def some_view(request):
... request.timings.start('something_to_time')
... # do something here
... request.timings.stop('something_to_time')
django_statsd Package¶
django_statsd
Package¶
settings
Module¶
-
django_statsd.settings.
STATSD_DEBUG
= True¶ Enable warnings such as timers which are started but not finished. Defaults to DEBUG if not configured
-
django_statsd.settings.
STATSD_HOST
= '127.0.0.1'¶ Statsd host, defaults to 127.0.0.1
-
django_statsd.settings.
STATSD_PORT
= '8125'¶ Statsd port, defaults to 8125
-
django_statsd.settings.
STATSD_PREFIX
= 'some_key_prefix'¶ Set the global statsd prefix if needed. Otherwise use the root
-
django_statsd.settings.
STATSD_SAMPLE_RATE
= 1.0¶ Statsd sample rate, lowering this decreases the (random) odds of actually submitting the data. Between 0 and 1 where 1 means always
-
django_statsd.settings.
STATSD_TAGS_LIKE
= None¶ Enable creating tags as well as the bare version. This causes an ajax view to be stored both as the regular view name and as the ajax tag. Supported separators are _is_ and =
-
django_statsd.settings.
STATSD_TRACK_MIDDLEWARE
= True¶ Enable tracking all requests using the middleware
celery
Module¶
database
Module¶
middleware
Module¶
-
class
django_statsd.middleware.
Client
(prefix='view')[source]¶ Bases:
object
-
class_
¶ alias of
statsd.client.Client
-
-
class
django_statsd.middleware.
Counter
(prefix='view')[source]¶ Bases:
django_statsd.middleware.Client
-
class_
¶ alias of
statsd.counter.Counter
-
-
class
django_statsd.middleware.
StatsdMiddleware
(get_response)[source]¶ Bases:
django.utils.deprecation.MiddlewareMixin
-
scope
= <thread._local object>¶
-
-
class
django_statsd.middleware.
Timer
(prefix='view')[source]¶ Bases:
django_statsd.middleware.Client
-
class_
¶ alias of
statsd.timer.Timer
-