@@ -34,10 +34,10 @@ def __init__(self, settings, environ):
3434
3535 @property
3636 def enabled (self ):
37- if platform .python_implementation () == "PyPy" :
37+ settings = global_settings ()
38+ if platform .python_implementation () == "PyPy" or not settings :
3839 return False
3940 else :
40- settings = global_settings ()
4141 return settings .gc_runtime_metrics .enabled
4242
4343 @property
@@ -55,18 +55,12 @@ def record_gc(self, phase, info):
5555 self .start_time = time .time ()
5656 elif phase == "stop" :
5757 total_time = time .time () - self .start_time
58- self .gc_time_metrics .record_custom_metric (
59- "GC/time/%d/all" % self .pid , total_time
60- )
58+ self .gc_time_metrics .record_custom_metric ("GC/time/%d/all" % self .pid , total_time )
6159 for gen in range (0 , 3 ):
6260 if gen <= current_generation :
63- self .gc_time_metrics .record_custom_metric (
64- "GC/time/%d/%d" % (self .pid , gen ), total_time
65- )
61+ self .gc_time_metrics .record_custom_metric ("GC/time/%d/%d" % (self .pid , gen ), total_time )
6662 else :
67- self .gc_time_metrics .record_custom_metric (
68- "GC/time/%d/%d" % (self .pid , gen ), 0
69- )
63+ self .gc_time_metrics .record_custom_metric ("GC/time/%d/%d" % (self .pid , gen ), 0 )
7064
7165 def start (self ):
7266 if hasattr (gc , "callbacks" ):
@@ -100,9 +94,7 @@ def __call__(self):
10094 if hasattr (gc , "get_objects" ):
10195 object_types = map (type , gc .get_objects ())
10296 if self .top_object_count_limit > 0 :
103- highest_types = Counter (object_types ).most_common (
104- self .top_object_count_limit
105- )
97+ highest_types = Counter (object_types ).most_common (self .top_object_count_limit )
10698 for obj_type , count in highest_types :
10799 yield (
108100 "GC/objects/%d/type/%s" % (self .pid , callable_name (obj_type )),
0 commit comments