Sha256: 60bf94cd9b6f51cdacbd8d9d46f716dc02e986335eb54db8bd9e31c7b3af8a8f
Contents?: true
Size: 1.07 KB
Versions: 9
Compression:
Stored size: 1.07 KB
Contents
module SemanticLogger module JRuby class GarbageCollectionLogger include Java::JavaxManagement::NotificationListener # Only log the garbage collection if the number of microseconds exceeds # this value def initialize(min_microseconds = 10_000) @min_microseconds = min_microseconds end # Must leave the method name as-is so that it can be found by Java def handleNotification(notification, _) # Only care about GARBAGE_COLLECTION_NOTIFICATION notifications return unless notification.get_type == Java::ComSunManagement::GarbageCollectionNotificationInfo::GARBAGE_COLLECTION_NOTIFICATION info = Java::ComSunManagement::GarbageCollectionNotificationInfo.from(notification.user_data) gc_info = info.gc_info duration = gc_info.duration return unless duration >= @min_microseconds SemanticLogger['GarbageCollector'].measure_warn( "Garbage Collection completed: #{info.gc_name} ##{gc_info.id}", duration: duration.to_f / 1000 ) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems