1- import threading as t
1+ import threading
22import resource
33import os
44import gc as gc_
@@ -69,7 +69,7 @@ class Metrics(object):
6969 ru_nsignals = 0
7070 ru_nvcs = 0
7171 ru_nivcsw = 0
72- dead_threads = 0
72+ dummy_threads = 0
7373 alive_threads = 0
7474 daemon_threads = 0
7575 gc = None
@@ -117,7 +117,7 @@ def __init__(self, sensor):
117117 self .sensor = sensor
118118
119119 def run (self ):
120- self .timer = t .Thread (target = self .collect_and_report )
120+ self .timer = threading .Thread (target = self .collect_and_report )
121121 self .timer .daemon = True
122122 self .timer .name = "Instana Metric Collection"
123123 self .timer .start ()
@@ -233,10 +233,10 @@ def collect_metrics(self):
233233 threshold1 = th [1 ],
234234 threshold2 = th [2 ])
235235
236- thr = t .enumerate ()
237- daemon_threads = [tr .daemon and tr . is_alive () for tr in thr ].count (True )
238- alive_threads = [not tr .daemon and tr . is_alive () for tr in thr ].count (True )
239- dead_threads = [not tr . is_alive () for tr in thr ].count (True )
236+ thr = threading .enumerate ()
237+ daemon_threads = [tr .daemon is True for tr in thr ].count (True )
238+ alive_threads = [tr .daemon is False for tr in thr ].count (True )
239+ dummy_threads = [type ( tr ) is threading . _DummyThread for tr in thr ].count (True )
240240
241241 m = Metrics (ru_utime = u [0 ] if not self .last_usage else u [0 ] - self .last_usage [0 ],
242242 ru_stime = u [1 ] if not self .last_usage else u [1 ] - self .last_usage [1 ],
@@ -255,7 +255,7 @@ def collect_metrics(self):
255255 ru_nvcs = u [14 ] if not self .last_usage else u [14 ] - self .last_usage [14 ],
256256 ru_nivcsw = u [15 ] if not self .last_usage else u [15 ] - self .last_usage [15 ],
257257 alive_threads = alive_threads ,
258- dead_threads = dead_threads ,
258+ dummy_threads = dummy_threads ,
259259 daemon_threads = daemon_threads ,
260260 gc = g )
261261
0 commit comments