https://github.com/schmichael/django-mmstats
Mmstats ❤ Django
https://github.com/schmichael/django-mmstats
Last synced: about 1 year ago
JSON representation
Mmstats ❤ Django
- Host: GitHub
- URL: https://github.com/schmichael/django-mmstats
- Owner: schmichael
- Created: 2012-02-17T02:32:29.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-03-09T07:23:42.000Z (over 14 years ago)
- Last Synced: 2025-03-25T14:21:56.812Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 97.7 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
=====
About
=====
Mmstats is a way to expose and read diagnostic values and metrics for
applications. Think of mmstats as /proc for your application.
This project is an integration between mmstats and Django and includes a base
mmstats model class (see ``django_mmstats/base.py``) and middleware (see
``django_mmstats/middleware.py``).
The middleware will create a ``request.stats`` mmstats instance on all request
objects record basic metrics like average response time and counters for each
status code.
=====
Usage
=====
See ``example/mmdjango`` for a full example of integrating Django and MmStats!
Step 0: pip install django-mmstats
----------------------------------
Install django-mmstats in your Django project's Python path.
Step 1: Create your own stats class
-----------------------------------
Create your own stats subclass. It can be as simple as:
::
from django_mmstats.base import BaseDjangoStats
class DjangoStats(BaseDjangoStats):
"""Add mmstats fields here, just like Django models!"""
Step 2: Edit your settings.py
-----------------------------
Make sure you include ``django_mmstats.middleware.MmStatsMiddleware`` in your
``MIDDLEWARE_CLASSES``.
Then add the following settings so the middleware knows where to find your stats:
::
# MmStats Settings!
import stats
MMSTATS_CLASS = stats.DjangoStats # Required
MMSTATS_OPTIONS = {} # Optional kwargs to pass to MMSTATS_CLASS
Step 3: Test it out!
--------------------
Run Django's test server and hit a couple pages. Then run ``slurpstats
$TMP/mmstats-*`` to see the stats collected!