Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-debug-toolbar-mongo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-debug-toolbar-mongo
Commits
db98ef8f
Commit
db98ef8f
authored
Oct 06, 2011
by
Colin Howe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to hide (costly) stacktraces
parent
0e05413c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
README.rst
+5
-0
debug_toolbar_mongo/operation_tracker.py
+11
-4
setup.py
+1
-1
No files found.
README.rst
View file @
db98ef8f
...
@@ -25,5 +25,10 @@ An extra panel titled "MongoDB" should appear in your debug toolbar.
...
@@ -25,5 +25,10 @@ An extra panel titled "MongoDB" should appear in your debug toolbar.
Note that this should work with any Django application that uses PyMongo.
Note that this should work with any Django application that uses PyMongo.
Obtaining stack traces can slow down queries significantly. To turn them off
add the following lines to your ``settings.py``::
DEBUG_TOOLBAR_MONGO_STACKTRACES = False
Disclaimer: only tested in latest Chrome, may fall to pieces in other browers.
Disclaimer: only tested in latest Chrome, may fall to pieces in other browers.
If you feel like fixing it, contributions are welcome!
If you feel like fixing it, contributions are welcome!
debug_toolbar_mongo/operation_tracker.py
View file @
db98ef8f
...
@@ -28,6 +28,13 @@ inserts = []
...
@@ -28,6 +28,13 @@ inserts = []
updates
=
[]
updates
=
[]
removes
=
[]
removes
=
[]
WANT_STACK_TRACE
=
getattr
(
settings
,
'DEBUG_TOOLBAR_MONGO_STACKTRACES'
,
True
)
def
_get_stacktrace
():
if
WANT_STACK_TRACE
:
return
_tidy_stacktrace
(
reversed
(
inspect
.
stack
()))
else
:
return
[]
# Wrap Cursor._refresh for getting queries
# Wrap Cursor._refresh for getting queries
@functools.wraps
(
_original_methods
[
'insert'
])
@functools.wraps
(
_original_methods
[
'insert'
])
...
@@ -47,7 +54,7 @@ def _insert(collection_self, doc_or_docs, manipulate=True,
...
@@ -47,7 +54,7 @@ def _insert(collection_self, doc_or_docs, manipulate=True,
'document'
:
doc_or_docs
,
'document'
:
doc_or_docs
,
'safe'
:
safe
,
'safe'
:
safe
,
'time'
:
total_time
,
'time'
:
total_time
,
'stack_trace'
:
_
tidy_stacktrace
(
reversed
(
inspect
.
stack
())
),
'stack_trace'
:
_
get_stacktrace
(
),
})
})
return
result
return
result
...
@@ -75,7 +82,7 @@ def _update(collection_self, spec, document, upsert=False,
...
@@ -75,7 +82,7 @@ def _update(collection_self, spec, document, upsert=False,
'spec'
:
spec
,
'spec'
:
spec
,
'safe'
:
safe
,
'safe'
:
safe
,
'time'
:
total_time
,
'time'
:
total_time
,
'stack_trace'
:
_
tidy_stacktrace
(
reversed
(
inspect
.
stack
())
),
'stack_trace'
:
_
get_stacktrace
(
),
})
})
return
result
return
result
...
@@ -96,7 +103,7 @@ def _remove(collection_self, spec_or_id, safe=False, **kwargs):
...
@@ -96,7 +103,7 @@ def _remove(collection_self, spec_or_id, safe=False, **kwargs):
'spec_or_id'
:
spec_or_id
,
'spec_or_id'
:
spec_or_id
,
'safe'
:
safe
,
'safe'
:
safe
,
'time'
:
total_time
,
'time'
:
total_time
,
'stack_trace'
:
_
tidy_stacktrace
(
reversed
(
inspect
.
stack
())
),
'stack_trace'
:
_
get_stacktrace
(
),
})
})
return
result
return
result
...
@@ -125,7 +132,7 @@ def _cursor_refresh(cursor_self):
...
@@ -125,7 +132,7 @@ def _cursor_refresh(cursor_self):
query_data
=
{
query_data
=
{
'time'
:
total_time
,
'time'
:
total_time
,
'operation'
:
'query'
,
'operation'
:
'query'
,
'stack_trace'
:
_
tidy_stacktrace
(
reversed
(
inspect
.
stack
())
),
'stack_trace'
:
_
get_stacktrace
(
),
}
}
# Collection in format <db_name>.<collection_name>
# Collection in format <db_name>.<collection_name>
...
...
setup.py
View file @
db98ef8f
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
...
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup
(
setup
(
name
=
'django-debug-toolbar-mongo'
,
name
=
'django-debug-toolbar-mongo'
,
version
=
'0.1.
2
'
,
version
=
'0.1.
3
'
,
description
=
'MongoDB panel for the Django Debug Toolbar'
,
description
=
'MongoDB panel for the Django Debug Toolbar'
,
long_description
=
open
(
'README.rst'
)
.
read
(),
long_description
=
open
(
'README.rst'
)
.
read
(),
author
=
'Harry Marr'
,
author
=
'Harry Marr'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment