Debugging¶
Debugging Guillotina will be slightly different from other web application that are not asyncio but Guillotina provides some nice integration to help you out.
X-Debug header¶
Any any request, you can provide the header X-Debug:1
and
Guillotina will output debugging headers in the response
about timing, number of queries and cache hit/miss stats.
-
GET
/
(db)/
(container)¶ Retrieves serialization of resource
- Permission: guillotina.ViewContent
- Context: guillotina.interfaces.content.IResource
GET /db/container HTTP/1.1 Accept: application/json Authorization: Basic cm9vdDpyb290 X-Debug: 1
curl -i http://nohost/db/container -H 'Accept: application/json' -H 'X-Debug: 1' --user root:root
http http://nohost/db/container Accept:application/json X-Debug:1 -a root:root
HTTP/1.1 200 OK Content-Length: 512 Content-Type: application/json XG-Num-Queries: 0 XG-Request-Cache-hits: 0 XG-Request-Cache-misses: 3 XG-Request-Cache-stored: 3 XG-Timing-0-start: 0.28300 XG-Timing-1-traversed: 0.24796 XG-Timing-2-beforeauthentication: 0.07486 XG-Timing-3-authentication: 0.07129 XG-Timing-4-viewfound: 0.20742 XG-Timing-5-authorization: 0.58866 XG-Timing-6-viewrender: 0.02789 XG-Timing-7-viewrendered: 0.96989 XG-Timing-8-renderer: 0.10133 XG-Timing-9-headers: 0.01621 XG-Timing-Total: 2.58851 XG-Total-Cache-hits: 0 XG-Total-Cache-misses: 6 XG-Total-Cache-stored: 6 { "@id": "http://127.0.0.1:56609/db/container", "@type": "Container", "@name": "container", "@uid": "94fdd84ea52a4e49afca09073ec7f0a9", "@static_behaviors": [], "parent": {}, "is_folderish": true, "creation_date": "2019-08-24T12:41:21.224751+00:00", "modification_date": "2019-08-24T12:41:21.224751+00:00", "UID": "94fdd84ea52a4e49afca09073ec7f0a9", "type_name": "Container", "title": "container", "uuid": "94fdd84ea52a4e49afca09073ec7f0a9", "__behaviors__": [], "__name__": "container", "items": [], "length": 0 }
Query Parameters: - include (string) –
- omit (string) –
Status Codes: - 200 OK – Resource data
- 401 Unauthorized – You are not authorized to perform the operation
- 404 Not Found – The resource does not exist
GDEBUG¶
On startup, you can also provide the environment variable GDEBUG=true
.
This will provide detailed query statistics with the X-Debug:1
.
aiomonitor¶
Guillotina also provides integration with the aiomonitor
python module.
This module allows you to attach to a running python with asyncio
to inspect the active tasks running.
First, install aiomonitor:
pip install aiomonitor
Then, run guillotina with --monitor
:
g server --monitor
Finally, connect to it:
python -m aiomonitor.cli
Jupyter¶
Guillotina also works with Jupyter notebooks. Load the example notebook in the guillotina repository to see an example of how to get started.