wolph / django-statsd Goto Github PK
View Code? Open in Web Editor NEWDjango Statsd library to track the page load times with Graphite
Home Page: http://django-stats.readthedocs.io/en/latest/usage.html
Django Statsd library to track the page load times with Graphite
Home Page: http://django-stats.readthedocs.io/en/latest/usage.html
Should be pretty simple if the lowest supported version becomes Django 1.10
We are experiencing an issue with our django app where anytime there is a 404 error, the skip_view
function tries to match against a view without a name, and then regex throws an error trying to match against None
.
After a little more investigation the view it is trying to compare to is the StatsdMiddleware
which has a view_name
of None
if re.match(pattern, view_name):
File "/usr/lib/python3.7/re.py", line 173, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
This is causing a 500 error for every 404.
I'm not sure if we have something misconfigured somewhere or if this is a bug of some kind. Does anyone have any insight or advice about this problem?
Can't install this version using pip...
pip install --upgrade django-statsd
Downloading/unpacking django-statsd from http://pypi.python.org/packages/any/d/django-statsd/django-statsd-1.8.0.freebsd-7.2-RELEASE-amd64.tar.gz#md5=44375a6e8b14e7681f77a0bcb675141a
Downloading django-statsd-1.8.0.freebsd-7.2-RELEASE-amd64.tar.gz
Running setup.py egg_info for package django-statsd
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: '/opt/virtualenvs/arribaa/build/django-statsd/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: '/opt/virtualenvs/arribaa/build/django-statsd/setup.py'
We typically wrap all non-critical components in a try/catch block in Django's settings.py
, ie.
STATSD_PREFIX = 'django'
try:
import django_statsd
INSTALLED_APPS += (
'django_statsd',
)
MIDDLEWARE = (
'django_statsd.middleware.StatsdMiddleware',
) + MIDDLEWARE + (
'django_statsd.middleware.StatsdMiddlewareTimer',
)
except:
pass
But because django_statsd
evaluates its own settings in the import, this happens before the Django-level settings have actually been registered, so it doesn't see any of them (ie. STATSD_PREFIX
here doesn't get picked up)
Honestly, this doesn't look fixable without major changes, so I'm planning to work around it. But it seemed worth raising in case I'm wrong about that.
Hi,
what do you think about to add a new setting with wildcards for those views that you want to track instead of just to track everything with the middleware?
The use case is avoid to send data about django admin for example.
It would be helpful to document the available settings. Attempting to configure this for the first time and reading through the source code to figure it out but there are a lot of moving pieces. I am not familiar enough with any of this to be of any help but figured I would open the issue
The new 1.9.0 release of django-statsd cannot be installed if python-statsd is not already present:
$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 7, in <module>
import django_statsd
File "/Users/priteau/django-statsd-1.9.0/django_statsd/__init__.py", line 1, in <module>
from django_statsd.middleware import (
File "/Users/priteau/django-statsd-1.9.0/django_statsd/middleware.py", line 8, in <module>
import statsd
ImportError: No module named statsd
This is caused by this import: https://github.com/WoLpH/django-statsd/blob/v1.9.0/setup.py#L7
I'm comparing this with the django-statsd-mozilla package. Both work out of the box, but the other better supports SQL and cache timing. On the other hand, your package has a recent pull request and covers json parse/load and rendering time. Have you given any thought to finishing the work in django_statsd.database
? Would you be open to a pull request to do so?
When response is returned from middleware, we are getting following error.
STATSD_TRACK_MIDDLEWARE = True
File "~/.virtualenvs/doconpy/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "~/.virtualenvs/doconpy/lib/python3.6/site-packages/django/utils/deprecation.py", line 142, in __call__
response = self.process_response(request, response)
File "~/.virtualenvs/doconpy/lib/python3.6/site-packages/django_statsd/middleware.py", line 198, in process_response
StatsdMiddleware.scope.timings.stop('process_response')
File "~/.virtualenvs/doconpy/lib/python3.6/site-packages/django_statsd/middleware.py", line 103, in stop
'started tracking it' % key)
AssertionError: Unable to stop tracking process_response, never started tracking it
2.5.2 is tagged as latest but both in document and source code mismatch exists
the breaking part fixed in the latest is is_ajax
function which is not released.
During development, should be really helpful to have a dummy statsd client that instead of try to send the metrics to the real statsd, it just print logs with the metrics that you're trying to send.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.