Class RulesChronoChartRecorder

java.lang.Object
org.kie.api.event.rule.DefaultAgendaEventListener
org.droolsassert.RulesChronoAgendaEventListener
org.droolsassert.RulesChronoChartRecorder
All Implemented Interfaces:
EventListener, org.kie.api.event.rule.AgendaEventListener

public class RulesChronoChartRecorder extends RulesChronoAgendaEventListener
Collect live performance statistic for rules (then block) as aggregated result and jfree chart TimeSeries.
Suitable for prod environment and statistic delivery at the end of the flow or exposing via rest API etc.

Note: This class creates thread pool executor with single background thread (for all instances) with core pool size 0 (thread will stop if no statistic is gathered).
Executor holds week reference to the recorder and scheduled periodic statistic gathering will be automatically cancelled when recorder is not in use any more.
See Also:
  • Field Details

    • RETENTION_PERIOD_MIN

      public static final int RETENTION_PERIOD_MIN
    • rulesMaxChart

      protected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> rulesMaxChart
    • rulesAvgChart

      protected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> rulesAvgChart
    • rulesMinChart

      protected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> rulesMinChart
    • globalMaxChart

      protected org.jfree.data.time.TimeSeries globalMaxChart
    • globalAvgChart

      protected org.jfree.data.time.TimeSeries globalAvgChart
    • globalMinChart

      protected org.jfree.data.time.TimeSeries globalMinChart
    • retentionPeriodSec

      protected long retentionPeriodSec
  • Constructor Details

    • RulesChronoChartRecorder

      public RulesChronoChartRecorder()
      Creates RulesChronoChartRecorder with no session prefix and default aggregation period
    • RulesChronoChartRecorder

      public RulesChronoChartRecorder(long aggregationPeriodMs)
      Creates RulesChronoChartRecorder with no session prefix and provided aggregation period
      Parameters:
      aggregationPeriodMs -
  • Method Details

    • withRetentionPeriod

      public RulesChronoChartRecorder withRetentionPeriod(long time, TimeUnit units)
      Retain last 3h chart data by default
    • withDataTypes

      public RulesChronoChartRecorder withDataTypes(RulesChronoChartRecorder.DataType... dataTypes)
      Per rule and global (generalized) chart data is gathered by default
    • withMaxThreshold

      public RulesChronoChartRecorder withMaxThreshold(double threshold)
      Start gather chart data only if threshold value reached
    • withAvgThreshold

      public RulesChronoChartRecorder withAvgThreshold(double threshold)
      Start gather chart data only if threshold value reached
    • withMinThreshold

      public RulesChronoChartRecorder withMinThreshold(double threshold)
      Start gather chart data only if threshold value reached
    • withPackageName

      public RulesChronoChartRecorder withPackageName(boolean usePackageName)
      Description copied from class: RulesChronoAgendaEventListener
      Include rule package name to qualify rule name, false by default
      Overrides:
      withPackageName in class RulesChronoAgendaEventListener
    • withSessionPrefix

      public RulesChronoChartRecorder withSessionPrefix(String sessionPrefix)
      Description copied from class: RulesChronoAgendaEventListener
      Include unique session prefix to segregate statistic.
      Optional unless you want to use different aggregation periods for the same rule names.
      If several listeners gather statistic under the same name statistic will be merged and 'peer' counter increased.
      Overrides:
      withSessionPrefix in class RulesChronoAgendaEventListener
    • recordTimeSeries

      protected void recordTimeSeries()
    • getRulesMaxChart

      public TreeMap<String,org.jfree.data.time.TimeSeries> getRulesMaxChart()
    • getRulesAvgChart

      public TreeMap<String,org.jfree.data.time.TimeSeries> getRulesAvgChart()
    • getRulesMinChart

      public TreeMap<String,org.jfree.data.time.TimeSeries> getRulesMinChart()
    • getGlobalMaxChart

      public org.jfree.data.time.TimeSeries getGlobalMaxChart()
    • getGlobalAvgChart

      public org.jfree.data.time.TimeSeries getGlobalAvgChart()
    • getGlobalMinChart

      public org.jfree.data.time.TimeSeries getGlobalMinChart()
    • isRecordingStarted

      public boolean isRecordingStarted()
    • reset

      public void reset()
      Overrides:
      reset in class RulesChronoAgendaEventListener