Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jazzband/django-silk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.3
Choose a base ref
...
head repository: jazzband/django-silk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.3.1
Choose a head ref
  • 16 commits
  • 25 files changed
  • 1 contributor

Commits on Jun 22, 2014

  1. Docs

    mtford90 committed Jun 22, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    86862c8 View commit details
  2. docs

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    90b7963 View commit details
  3. test rtd webhook

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    1535225 View commit details
  4. more rtd test

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    710c369 View commit details
  5. docs progress

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    ea817e4 View commit details
  6. more docs

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    fa40c47 View commit details
  7. more docs

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    51a6e4a View commit details
  8. more docs

    mtford90 committed Jun 22, 2014
    Copy the full SHA
    792ac04 View commit details

Commits on Jun 26, 2014

  1. fixes to urls

    mtford90 committed Jun 26, 2014
    Copy the full SHA
    dc90529 View commit details

Commits on Jul 2, 2014

  1. Copy the full SHA
    c14b50f View commit details

Commits on Jul 4, 2014

  1. bug fixes

    mtford90 committed Jul 4, 2014
    Copy the full SHA
    14d247c View commit details
  2. removed pinning

    mtford90 committed Jul 4, 2014
    Copy the full SHA
    264938e View commit details

Commits on Jul 5, 2014

  1. Bug fixes

    mtford90 committed Jul 5, 2014
    Copy the full SHA
    6caa537 View commit details
  2. Fixed setup.py

    mtford90 committed Jul 5, 2014
    Copy the full SHA
    47eaebd View commit details
  3. Sorted out version pinning

    mtford90 committed Jul 5, 2014
    Copy the full SHA
    0f4bbe0 View commit details
  4. prep for release

    mtford90 committed Jul 5, 2014
    Copy the full SHA
    b62bfd6 View commit details
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -64,3 +64,7 @@ dist

# Pip
/src

# Sphinx

_html
143 changes: 67 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,33 +2,21 @@

[![Build Status](https://travis-ci.org/mtford90/silk.svg?branch=master)](https://travis-ci.org/mtford90/silk)

Silk is a live profiling and inspection tool for the Django framework. It primarily consists of:
Silk is a live profiling and inspection tool for the Django framework. Silk intercepts and stores HTTP requests and database queries before presenting them in a user interface for further inspection:

* Middleware for intercepting Requests/Responses
* A wrapper around SQL execution for profiling of database queries
* A context manager/decorator for profiling blocks of code and functions either manually or dynamically.
* A user interface for inspection and visualisation of the above.
<img src="https://raw.githubusercontent.com/mtford90/silk/master/screenshots/1.png" width="720px"/>

Documentation is below and a live demo is available at [http://mtford.co.uk/silk/](http://mtford.co.uk/silk/), where the tool is actively profiling my website and blog!
Documentation is available [here](http://silk.readthedocs.org/en/latest/) and there is also [live demo](http://mtford.co.uk/silk/) to play around with.

## Contents

* [Requirements](#requirements)
* [Features](#features)
* [Request Inspection](#request-inspection)
* [SQL Inspection](#sql-inspection)
* [Profiling](#profiling)
* [Decorator](#decorator)
* [Context Manager](#context-manager)
* [Experimental Features](#experimental-features)
* [Dynamic Profiling](#dynamic-profiling)
* [Code Generation](#code-generation)
* [Installation](#installation)
* [Features](#features)
* [Configuration](#configuration)
* [Authentication/Authorisation](#authentication-authorisation)
* [Request/Response bodies](#request-response-bodies)
* [Meta-Profiling](#meta-profiling)
* [Roadmap](#roadmap)

## Requirements

@@ -39,8 +27,70 @@ Silk has been tested with:

I left out Django <1.5 due to the change in `{% url %}` syntax. Python 2.6 is missing `collections.Counter`. Python 3.0 and 3.1 are not available via Travis and also are missing the `u'xyz'` syntax for unicode. Workarounds can likely be found for all these if there is any demand. Django 1.7 is currently untested.

## Installation

Via pip into a virtualenv:

```bash
pip install django-silk
```

In `settings.py` add the following:

```python
MIDDLEWARE_CLASSES = (
...
'silk.middleware.SilkyMiddleware',
...
)

INSTALLED_APPS = (
...
'silk'
)
```

Note: The middleware is placement sensitive. If the middleware before `silk.middleware.SilkyMiddleware` returns from `process_request` then `SilkyMiddleware` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from `process_request`. See the [django docs](https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request) for more information on this.

To enable access to the user interface add the following to your `urls.py`:

```python
urlpatterns += patterns('', url(r'^silk', include('silk.urls', namespace='silk')))
```

before running syncdb:

```python
python manage.py syncdb
```

Silk will automatically begin interception of requests and you can proceed to add profiling
if required. The UI can be reached at `/silk/`

### Alternative Installation

Via [github tags](https://github.com/mtford90/silk/releases):

```bash
pip install django-silk-<version>.tar.gz
```

You can install from master using the following, but please be aware that the version in master
may not be working for all versions specified in [requirements](#requirements)

```bash
pip install -e git+https://github.com/mtford90/silk.git#egg=silk
```

## Features

Silk primarily consists of:

* Middleware for intercepting Requests/Responses
* A wrapper around SQL execution for profiling of database queries
* A context manager/decorator for profiling blocks of code and functions either manually or dynamically.
* A user interface for inspection and visualisation of the above.

### Request Inspection

The Silk middleware intercepts and stores requests and responses and stores them in the configured database.
@@ -132,11 +182,7 @@ def post(request, post_id):
})
```

## Experimental Features

The below features are still in need of thorough testing and should be considered experimental.

### Dynamic Profiling
#### Dynamic Profiling

One of Silk's more interesting features is dynamic profiling. If for example we wanted to profile a function in a dependency to which we only have read-only access (e.g. system python libraries owned by root) we can add the following to `settings.py` to apply a decorator at runtime:

@@ -245,61 +291,6 @@ Silk currently generates two bits of code per request:

Both are intended for use in replaying the request. The curl command can be used to replay via command-line and the python code can be used within a Django unit test or simply as a standalone script.

## Installation

Via pip into a virtualenv:

```bash
pip install django-silk
```

Via [github tags](https://github.com/mtford90/silk/releases):

```bash
pip install django-silk-<version>.tar.gz
```

You can install from master using the following, but please be aware that the version in master
may not be working for all versions specified in [requirements](#requirements)

```bash
pip install -e git+https://github.com/mtford90/silk.git#egg=silk
```

Once silk is installed on your system/venv we then need to configure your Django project.

In `settings.py` add the following:

```python
MIDDLEWARE_CLASSES = (
...
'silk.middleware.SilkyMiddleware',
...
)

INSTALLED_APPS = (
...
'silk'
)
```

Note: The middleware is placement sensitive. If the middleware before `silk.middleware.SilkyMiddleware` returns from `process_request` then `SilkyMiddleware` will never get the chance to execute. Therefore you must ensure that any middleware placed before never returns anything from `process_request`. See the [django docs](https://docs.djangoproject.com/en/dev/topics/http/middleware/#process-request) for more information on this.

To enable access to the user interface add the following to your `urls.py`:

```python
urlpatterns += patterns('', url(r'^silk', include('silk.urls', namespace='silk')))
```

before running syncdb:

```python
python manage.py syncdb
```

Silk will automatically begin interception of requests and you can proceed to add profiling
if required. The UI can be reached at `/silk/`

## Configuration

### Authentication/Authorisation
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -11,5 +11,4 @@ It primarily consists of:
- A user interface for inspection and visualisation of the above.

Documentation is available at https://github.com/mtford90/silk and a live demo is available at
http://mtford.co.uk/silk/, where the tool is actively profiling my
website and blog!
http://mtford.co.uk/silk/.
177 changes: 177 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/silk.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/silk.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/silk"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/silk"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."

xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."

pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
Loading