Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SILKY_MIDDLEWARE_CLASS option #334

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ INSTALLED_APPS = (

**Note:** If you are using `django.middleware.gzip.GZipMiddleware`, place that **before** `silk.middleware.SilkyMiddleware`, otherwise you will get an encoding error.

If you want to use custom middleware, for example you developed the subclass of `silk.middleware.SilkyMiddleware`, so you can use this combination of settings:

```python
# Specify the path where is the custom middleware placed
SILKY_MIDDLEWARE_CLASS = 'path.to.your.middleware.MyCustomSilkyMiddleware'

# Use this variable in list of middleware
MIDDLEWARE = [
...
SILKY_MIDDLEWARE_CLASS,
...
]
```

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

```python
Expand Down
3 changes: 2 additions & 1 deletion silk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class SilkyConfig(six.with_metaclass(Singleton, object)):
'SILKY_INTERCEPT_PERCENT': 100,
'SILKY_INTERCEPT_FUNC': None,
'SILKY_PYTHON_PROFILER': False,
'SILKY_STORAGE_CLASS': 'silk.storage.ProfilerResultStorage'
'SILKY_STORAGE_CLASS': 'silk.storage.ProfilerResultStorage',
'SILKY_MIDDLEWARE_CLASS': 'silk.middleware.SilkyMiddleware'
}

def _setup(self):
Expand Down
2 changes: 1 addition & 1 deletion silk/profiling/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _silk_installed(self):
middlewares = getattr(settings, 'MIDDLEWARE', [])
if not middlewares:
middlewares = []
middleware_installed = 'silk.middleware.SilkyMiddleware' in middlewares
middleware_installed = SilkyConfig().SILKY_MIDDLEWARE_CLASS in middlewares
return app_installed and middleware_installed

def _should_profile(self):
Expand Down