From: Fredrik Tolf Date: Thu, 12 May 2016 17:01:44 +0000 (+0200) Subject: python: Added more info to perf request objects. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=64c8865417aedcf88ff3f6f647ee2ccf4a3522ed;p=ashd.git python: Added more info to perf request objects. --- diff --git a/python/ashd/perf.py b/python/ashd/perf.py index 97146a8..c74e443 100644 --- a/python/ashd/perf.py +++ b/python/ashd/perf.py @@ -16,8 +16,13 @@ if pdm: self.method = env.get("REQUEST_METHOD") self.uri = env.get("REQUEST_URI") self.host = env.get("HTTP_HOST") + self.script_uri = env.get("SCRIPT_NAME") + self.script_path = env.get("SCRIPT_FILENAME") + self.pathinfo = env.get("PATH_INFO") + self.querystring = env.get("QUERY_STRING") self.remoteaddr = env.get("REMOTE_ADDR") self.remoteport = env.get("REMOTE_PORT") + self.scheme = env.get("wsgi.url_scheme") class reqfinish(pdm.perf.finishevent): def __init__(self, start, aborted, status): diff --git a/python3/ashd/perf.py b/python3/ashd/perf.py index 6942424..3b8f63b 100644 --- a/python3/ashd/perf.py +++ b/python3/ashd/perf.py @@ -3,6 +3,11 @@ try: import pdm.perf except: pdm = None +try: + import resource + ru_thread = resource.RUSAGE_THREAD +except: + ru_thread = None reqstat = {} @@ -17,13 +22,25 @@ if pdm: self.method = env.get("REQUEST_METHOD") self.uri = env.get("REQUEST_URI") self.host = env.get("HTTP_HOST") + self.script_uri = env.get("SCRIPT_NAME") + self.script_path = env.get("SCRIPT_FILENAME") + self.pathinfo = env.get("PATH_INFO") + self.querystring = env.get("QUERY_STRING") self.remoteaddr = env.get("REMOTE_ADDR") self.remoteport = env.get("REMOTE_PORT") + self.scheme = env.get("wsgi.url_scheme") + if ru_thread is not None: + ru = resource.getrusage(ru_thread) + self.icpu = ru.ru_utime + ru.ru_stime class reqfinish(pdm.perf.finishevent): def __init__(self, start, aborted, status): super().__init__(start, aborted) self.status = status + self.cputime = 0 + if ru_thread is not None: + ru = resource.getrusage(ru_thread) + self.cputime = ru.ru_utime + ru.ru_stime - start.icpu class request(object): def __init__(self, env):