Skip to content

Commit fa976c1

Browse files
committed
Add options to set latency limits
Adding command line options to the report generator to specify per transaction type latency limits. 5s maximum response time is totally outdated.
1 parent 0e5b3af commit fa976c1

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

  • src/main/resources/generateReport

src/main/resources/generateReport/main.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,46 @@ def main():
1212
opt_template = 'report_simple.html'
1313
opt_resultdir = None
1414
opt_os_metrics = []
15+
opt_tt_limit = {
16+
'NEW_ORDER': 5.0,
17+
'PAYMENT': 5.0,
18+
'ORDER_STATUS': 5.0,
19+
'STOCK_LEVEL': 20.0,
20+
'DELIVERY': 5.0,
21+
'DELIVERY_BG': 80.0
22+
}
1523
opt_help = False
1624
errors = False
1725

18-
opts, args = getopt.getopt(sys.argv[1:], 't:r:c:m:d:i:h?',
19-
['template=', 'resultdir=',
26+
opts, args = getopt.getopt(sys.argv[1:], 't:r:l:c:m:d:i:h?',
27+
['template=', 'resultdir=', 'limit=',
2028
'cpu=', 'memory=', 'disk=', 'interface=',
2129
'help'])
2230
for opt, val in opts:
2331
if opt in ['-t', '--template',]:
2432
opt_template = val
2533
elif opt in ['-r', '--resultdir',]:
2634
opt_resultdir = val
35+
elif opt in ['-l', '--limit',]:
36+
sval = val.split('=')
37+
if len(sval) != 2:
38+
print("invalid limit specification: {}".format(val),
39+
file = sys.stderr)
40+
errors = True
41+
continue
42+
tt = sval[0].upper()
43+
if tt not in opt_tt_limit:
44+
print("unknown transaction type: {}".format(tt),
45+
file = sys.stderr)
46+
errors = True
47+
continue
48+
try:
49+
opt_tt_limit[tt] = float(sval[1])
50+
except Exception as e:
51+
print("invalid limit specification: {}".format(str(e)),
52+
file = sys.stderr)
53+
errors = True
54+
continue
2755
elif opt in ['-c', '--cpu',]:
2856
sval = val.split(':')
2957
if len(sval) != 2:
@@ -32,6 +60,7 @@ def main():
3260
print("use HOSTNAME:ALIAS".format(val),
3361
file = sys.stderr)
3462
errors = True
63+
continue
3564
opt_os_metrics.append(('cpu', sval[0], sval[1]))
3665
elif opt in ['-m', '--memory',]:
3766
sval = val.split(':')
@@ -41,6 +70,7 @@ def main():
4170
print("use HOSTNAME:ALIAS".format(val),
4271
file = sys.stderr)
4372
errors = True
73+
continue
4474
opt_os_metrics.append(('memory', sval[0], sval[1]))
4575
elif opt in ['-d', '--disk',]:
4676
sval = val.split(':')
@@ -50,6 +80,8 @@ def main():
5080
print("use HOSTNAME:ALIAS:DEVICENAME".format(val),
5181
file = sys.stderr)
5282
errors = True
83+
print("invalid host specification: {}".format(val),
84+
file = sys.stderr)
5385
opt_os_metrics.append(('disk', sval[0], sval[1], sval[2]))
5486
elif opt in ['-i', '--interface',]:
5587
sval = val.split(':')
@@ -59,6 +91,7 @@ def main():
5991
print("use HOSTNAME:ALIAS:DEVICENAME".format(val),
6092
file = sys.stderr)
6193
errors = True
94+
continue
6295
opt_os_metrics.append(('interface', sval[0], sval[1], sval[2]))
6396
elif opt in ['-?', '-h', '--help']:
6497
opt_help = True
@@ -71,6 +104,7 @@ def main():
71104
return 2
72105

73106
result = bmsqlResult.bmsqlResult(opt_resultdir)
107+
result.tt_limit = opt_tt_limit
74108
for tt in result.ttypes:
75109
break
76110
print("count {} = {}".format(tt, result.num_trans(tt)))
@@ -136,15 +170,10 @@ def summary_data(result):
136170
# ----
137171
# Determine the percentiles and the latency limit
138172
# ----
139-
if tt == 'DELIVERY_BG':
140-
limit = 80.0
141-
elif tt == 'STOCK_LEVEL':
142-
limit = 20.0
143-
else:
144-
limit = 5.0
145173
ninth = result.percentile(tt, 0.9)
146174
n5th = result.percentile(tt, 0.95)
147175
n9th = result.percentile(tt, 0.99)
176+
limit = result.tt_limit[tt]
148177

149178
# ----
150179
# From that numbers we derive the color for the percentile numbers

0 commit comments

Comments
 (0)