From 054e34f00e258b7fc541b996bd0d703a23962f5b Mon Sep 17 00:00:00 2001 From: Aditya Hase Date: Tue, 25 Dec 2018 16:01:15 +0530 Subject: [PATCH] refactor(recorder): Do not profile --- frappe/middlewares.py | 16 +--------------- .../public/js/frappe/recorder/RequestDetail.vue | 9 --------- frappe/www/recorder.py | 4 ---- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/frappe/middlewares.py b/frappe/middlewares.py index f5af3c0c64..ba3538aa4b 100644 --- a/frappe/middlewares.py +++ b/frappe/middlewares.py @@ -38,16 +38,6 @@ class RecorderMiddleware(object): def __call__(self, environ, start_response): response_body = [] - def persist(uuid, stats): - # Keys of stats.stats are tuples, JSON doesn't like that, str(key) works - # First four entries in values are interesting numbers - # Last value is a dictionary of mapping of callers to tuple of number same four numbers - # We don't actually need this redundancy - _stats = { - str(key): value[:4] + tuple(value[4]) for key, value in stats.stats.items() - } - frappe.cache().set("recorder-stats-{}".format(uuid), json.dumps(_stats)) - def catching_start_response(status, headers, exc_info=None): start_response(status, headers, exc_info) return response_body.append @@ -63,11 +53,7 @@ class RecorderMiddleware(object): # SQL calls and profile details can't be recorded and accessed without this environ["uuid"] = str(uuid.uuid1()) - profile = Profile() - profile.runcall(runapp) + runapp() body = [b''.join(response_body)] - stats = Stats(profile) - - persist(environ["uuid"], stats) return body diff --git a/frappe/public/js/frappe/recorder/RequestDetail.vue b/frappe/public/js/frappe/recorder/RequestDetail.vue index e334d6f622..911b05587a 100644 --- a/frappe/public/js/frappe/recorder/RequestDetail.vue +++ b/frappe/public/js/frappe/recorder/RequestDetail.vue @@ -37,13 +37,6 @@ - - -
-
- {{ stat }}
-
-
@@ -54,7 +47,6 @@ export default { return { cache: [], calls: [], - stats: [], }; }, mounted() { @@ -66,7 +58,6 @@ export default { }).then( r => { this.cache = r.message.cache this.calls = r.message.calls - this.stats = r.message.stats }) }, }; diff --git a/frappe/www/recorder.py b/frappe/www/recorder.py index bbf4f5291a..1351e1a325 100644 --- a/frappe/www/recorder.py +++ b/frappe/www/recorder.py @@ -32,9 +32,6 @@ def get_request_data(uuid): for index, call in enumerate(calls): call["index"] = index - stats = frappe.cache().get("recorder-stats-{}".format(uuid)) - mapper = lambda stat: {"name": stat[0], "numbers": stat[1][:4], "callers": stat[1][4] if len(stat[1]) == 5 else []} - cache = frappe.cache().get("recorder-calls-cache-{}".format(uuid)) cache = json.loads(cache.decode()) for index, call in enumerate(cache): @@ -43,6 +40,5 @@ def get_request_data(uuid): return { "cache": cache, "calls": calls, - "stats": list(map(mapper, json.loads(stats).items())), }