Class | Logging::Stats::Tracker |
In: |
lib/logging/stats.rb
|
Parent: | Object |
The Tracker class provides synchronized access to a collection of related samplers.
stats | [R] |
Coalesce the samplers from the other tracker into this one. The other tracker is not modified by this method.
Coalescing the same two trackers multiple times should only be done if one of the trackers is reset between calls to this method. Otherwise statistics will be counted multiple times.
Only this tracker is locked when the coalescing is happening. It is left to the user to lock the other tracker if that is the desired behavior. This is a deliberate choice in order to prevent deadlock situations where two threads are contending on the same mutex.
Periodically execute the given block at the given period. The tracker will be locked while the block is executing.
This method is useful for logging statistics at given interval.
Example
periodically_run( 300 ) { logger = Logging::Logger['stats'] tracker.each {|sampler| logger << sampler.to_s} tracker.reset }
Obtains an exclusive lock, runs the block, and releases the lock when the block completes. This method is re-entrant so that a single thread can call sync multiple times without hanging the thread.