Skip to content

Instantly share code, notes, and snippets.

@novel
Created February 3, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save novel/3df0828cb1ab57de9ba6880243641ce1 to your computer and use it in GitHub Desktop.
Save novel/3df0828cb1ab57de9ba6880243641ce1 to your computer and use it in GitHub Desktop.
import pprint
from osprofiler.drivers.base import get_driver
CONN = "mongodb://localhost"
if __name__ == "__main__":
drv = get_driver(CONN)
fields = ['base_id', 'timestamp', 'info.request.path']
traces = drv.list_traces({}, fields)
for trace in traces:
if trace['info']:
report = drv.get_report(trace['base_id'])
print "%s %s: %s sec" % (trace['base_id'],
trace['info']['request']['path'],
int(report['info']['finished'] / 1000.0))
per_request_aggr_time = 0
for k, v in report['stats'].items():
per_request_aggr_time += int(v["duration"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment