From 1c8afed7aade80441afd7f44b95478b64589747a Mon Sep 17 00:00:00 2001 From: Thomas Maddox Date: Fri, 13 Sep 2013 11:08:34 -0500 Subject: [PATCH 1/2] fixed request_id and added to pretty.py as well --- reports/error_details.py | 4 +--- reports/pretty.py | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/reports/error_details.py b/reports/error_details.py index 0842471..590f4b8 100644 --- a/reports/error_details.py +++ b/reports/error_details.py @@ -178,9 +178,7 @@ if __name__ == '__main__': uuid = uuid_dict['instance'] req_list = [] - for req_dict in inst_recs.get(uuid, []): - req = req_dict['request_id'] - + for req in inst_recs.get(uuid, []): raws = list(models.RawData.objects.filter(request_id=req) .exclude(event='compute.instance.exists') .values("id", "when", "routing_key", "old_state", diff --git a/reports/pretty.py b/reports/pretty.py index 654fc40..1303f5f 100644 --- a/reports/pretty.py +++ b/reports/pretty.py @@ -52,6 +52,21 @@ def make_report(yesterday=None, start_hour=0, hours=24, percentile=97, expiry = 60 * 60 # 1 hour cmds = ['create', 'rebuild', 'rescue', 'resize', 'snapshot'] + requests = models.RawData.objects.filter(when__gt=dstart, when__lte=dend)\ + .exclude(instance=None, + event='compute.instance.exists')\ + .values('request_id', 'instance')\ + .distinct() + inst_recs = {} + for request in requests: + uuid = request['instance'] + request_id = request['request_id'] + if uuid in inst_recs: + inst_recs[uuid].append(request_id) + else: + inst_recs[uuid] = [request_id] + + failures = {} # { key : {failure_type: count} } durations = {} attempts = {} @@ -59,14 +74,7 @@ def make_report(yesterday=None, start_hour=0, hours=24, percentile=97, for uuid_dict in updates: uuid = uuid_dict['instance'] - # All the unique Request ID's for this instance during that timespan. - reqs = models.RawData.objects.filter(instance=uuid, - when__gt=dstart, when__lte=dend) \ - .values('request_id').distinct() - - - for req_dict in reqs: - req = req_dict['request_id'] + for req in inst_recs.get(uuid, []): raws = models.RawData.objects.filter(request_id=req)\ .exclude(event='compute.instance.exists')\ .order_by('when') From dfb591683315c6b999b16232607fba9af5f6ea25 Mon Sep 17 00:00:00 2001 From: Thomas Maddox Date: Fri, 13 Sep 2013 11:25:32 -0500 Subject: [PATCH 2/2] small tweak --- reports/error_details.py | 7 +++---- reports/pretty.py | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/reports/error_details.py b/reports/error_details.py index 590f4b8..9cc83d1 100644 --- a/reports/error_details.py +++ b/reports/error_details.py @@ -169,10 +169,9 @@ if __name__ == '__main__': for request in requests: uuid = request['instance'] request_id = request['request_id'] - if uuid in inst_recs: - inst_recs[uuid].append(request_id) - else: - inst_recs[uuid] = [request_id] + value = inst_recs.get(uuid, []) + value.append(request_id) + inst_recs[uuid] = value for uuid_dict in updates: uuid = uuid_dict['instance'] diff --git a/reports/pretty.py b/reports/pretty.py index 1303f5f..1cd1fe8 100644 --- a/reports/pretty.py +++ b/reports/pretty.py @@ -61,11 +61,9 @@ def make_report(yesterday=None, start_hour=0, hours=24, percentile=97, for request in requests: uuid = request['instance'] request_id = request['request_id'] - if uuid in inst_recs: - inst_recs[uuid].append(request_id) - else: - inst_recs[uuid] = [request_id] - + value = inst_recs.get(uuid, []) + value.append(request_id) + inst_recs[uuid] = value failures = {} # { key : {failure_type: count} } durations = {}