1616METRIC = 'etcd_request_duration_seconds'
1717
1818
19- def main (type , * args , ** kwargs ):
19+ def main (resource , * args , ** kwargs ):
2020 global v1
2121
2222 try :
@@ -44,11 +44,11 @@ def main(type, *args, **kwargs):
4444 k , v = part .split ('=' )
4545 labels [k ] = v .strip ('"' )
4646
47- if not labels .get ('type ' , '' ).endswith (type ):
47+ if not labels .get ('resource ' , '' ).endswith (resource ):
4848 continue
4949
5050 if labels ['operation' ] not in operations :
51- operations [labels ['operation' ]] = {'counts' : [], 'buckets' : [], 'type ' : labels ['type ' ]}
51+ operations [labels ['operation' ]] = {'counts' : [], 'buckets' : [], 'resource ' : labels ['resource ' ]}
5252 prev_value = 0
5353
5454 if metric .endswith ('_bucket' ):
@@ -61,15 +61,15 @@ def main(type, *args, **kwargs):
6161 operations [labels ['operation' ]]['count' ] = value
6262
6363 for operation , stats in operations .items ():
64- print (f"\n { stats ['sum' ] / stats ['count' ]:.3f} average { kwargs ['backend_name' ]} request duration (seconds): { operation } { stats ['type ' ]} " )
64+ print (f"\n { stats ['sum' ] / stats ['count' ]:.3f} average { kwargs ['backend_name' ]} request duration (seconds): { operation } { stats ['resource ' ]} " )
6565 fig = tpl .figure ()
6666 fig .barh (stats ['counts' ], stats ['buckets' ], max_width = 50 )
6767 fig .show ()
6868
6969
7070if __name__ == '__main__' :
7171 parser = argparse .ArgumentParser ()
72- parser .add_argument ('--type ' , '-t' , type = str , required = False , default = 'configmaps' )
72+ parser .add_argument ('--resource ' , '-t' , type = str , required = False , default = 'configmaps' )
7373 parser .add_argument ('--log-level' , '-l' , type = str , required = False , default = 'INFO' )
7474 parser .add_argument ('--backend-name' , '-b' , type = str , required = False , default = 'etcd' )
7575 args = parser .parse_args ()
0 commit comments