Class RuntimeEventAggregator

java.lang.Object
io.hypersistence.optimizer.core.event.persistence.RuntimeEventAggregator

public class RuntimeEventAggregator extends Object
The RuntimeEventAggregator rolls up runtime events into time windows so that a slow operation triggered many times is summarized as a handful of rows (one per window) carrying an occurrence count and, when available, the total and maximum durations, rather than one row per occurrence.

The aggregator is thread-safe: runtime events arrive from many application threads, while a single background thread periodically flushes the windows that have closed. On JVM shutdown, or when stop() is called, any remaining windows are flushed as well.

Since:
2.14.0
Author:
Vlad Mihalcea
  • Constructor Details

  • Method Details

    • start

      public void start()
      Start the background flush scheduler and register the JVM shutdown hook.
    • record

      public void record(Event event)
      Record a single runtime event into the current time window.
      Parameters:
      event - the runtime Event
    • flushClosedWindows

      public void flushClosedWindows(long referenceMillis)
      Flush every window whose end time is at or before the provided reference time.
      Parameters:
      referenceMillis - the reference time in milliseconds
    • flushAll

      public void flushAll()
      Flush all windows, regardless of whether they have closed.
    • stop

      public void stop()
      Stop the aggregator, flushing any remaining windows.
    • getDroppedCount

      public long getDroppedCount()
      Get the number of runtime events that were dropped because the signature cap was reached.
      Returns:
      the dropped count