mirror of https://github.com/jumpserver/jumpserver
perf: 添加 sql debug
parent
b9c1a89f51
commit
fa24a8e2f3
|
@ -101,6 +101,19 @@ class RefererCheckMiddleware:
|
|||
return response
|
||||
|
||||
|
||||
class SQLCountMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
if not settings.DEBUG_DEV:
|
||||
raise MiddlewareNotUsed
|
||||
|
||||
def __call__(self, request):
|
||||
from django.db import connection
|
||||
response = self.get_response(request)
|
||||
response['X-JMS-SQL-COUNT'] = len(connection.queries)
|
||||
return response
|
||||
|
||||
|
||||
class StartMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
|
|
@ -128,6 +128,7 @@ MIDDLEWARE = [
|
|||
'jumpserver.middleware.DemoMiddleware',
|
||||
'jumpserver.middleware.RequestMiddleware',
|
||||
'jumpserver.middleware.RefererCheckMiddleware',
|
||||
'jumpserver.middleware.SQLCountMiddleware',
|
||||
'orgs.middleware.OrgMiddleware',
|
||||
'authentication.backends.oidc.middleware.OIDCRefreshIDTokenMiddleware',
|
||||
'authentication.backends.cas.middleware.CASMiddleware',
|
||||
|
|
Loading…
Reference in New Issue