catcombo / django-speedinfo Goto Github PK
View Code? Open in Web Editor NEWDjango views profiler for small projects
License: MIT License
Django views profiler for small projects
License: MIT License
While not (easily) directly supported in the DB, ordering of calculated fields could be also provided.
This would allow to sort on e.g. "SQL time" also.
Do you think this is useful?
I have installed speedinfo on a test project. Initially it was throwing an error
Traceback (most recent call last):
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/core/management/__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Users/curatech/.virtualenvs/library/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/speedinfo/admin.py", line 132, in <module>
admin.site.register(ViewProfiler, ViewProfilerAdmin)
File "/Users/curatech/.virtualenvs/library/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 109, in register
raise AlreadyRegistered('The model %s is already registered' % model.__name__)
django.contrib.admin.sites.AlreadyRegistered: The model ViewProfiler is already registered
To prevent this, I have unregistered model.
from speedinfo.models import ViewProfiler
admin.site.unregister(ViewProfiler)
After this, setup was completed. I have browsed several pages on the app with toggle on and off but nothing is showing up in admin panel of speedinfo. Should I add any additional code to track the views?
I keep getting negative SQL count and SQL time for requests.
As a result of the above I also get division by zero
when opening the viewprofiler
page in admin panel.
Especially with DRF it is relevant if a request's response is of Content-Type text/html, text/json etc.
I think it would be nice to store this information (without the charset, i.e. everything up until ";").
What do you think?
Internal Server Error: /admin/
Traceback (most recent call last):
File "/Users/juli/dev/leansew/env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/Users/juli/dev/leansew/env/lib/python3.6/site-packages/speedinfo/middleware.py", line 112, in call
return self.process_response(request, response)
File "/Users/juli/dev/leansew/env/lib/python3.6/site-packages/speedinfo/middleware.py", line 90, in process_response
is_anon_call = request.user.is_anonymous()
TypeError: 'bool' object is not callable
What options are available for users if they have to add custom fields in the admin? For example, the percentile of total time.
One option is users can register the model by themselves. speedinfo has to ignore the registration if the model is already registered.
@catcombo I have been testing out speedinfo with several projects and it is working well. Thank you for your efforts.
Any reasons to use view_name instead of URL paths to collect statistics?
One issue with view names is, resolve
can't give full function name.
For example if there is a function at core.viewsets.BookViewSet.dashboard
, view name will be just core.viewsets.BookViewSet
. All the methods in the view set will have same view name. This results in combining stats of all views inside a model view set.
Another issue with view names is, when profiling views in admin, it will always show same view names like django.contrib.admin.options
, django.contrib.admin.options.changelist_view
irrespective of the model a user is visiting.
I have made a temporary fix to test it out 7bfc2c3
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.