refactor(recorder): Do not profile
This commit is contained in:
parent
b0362a307d
commit
054e34f00e
3 changed files with 1 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -37,13 +37,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<div v-for="stat in stats" :key="stat.name">
|
||||
{{ stat }}<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -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
|
||||
})
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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())),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue