Package org.droolsassert
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 chartTimeSeries.
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:
RulesChronoAgendaEventListener,PerfStat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRulesChronoChartRecorder.DataType
-
Field Summary
Fields Modifier and Type Field Description protected org.jfree.data.time.TimeSeriesglobalAvgChartprotected org.jfree.data.time.TimeSeriesglobalMaxChartprotected org.jfree.data.time.TimeSeriesglobalMinChartstatic intRETENTION_PERIOD_MINprotected longretentionPeriodSecprotected ConcurrentHashMap<String,org.jfree.data.time.TimeSeries>rulesAvgChartprotected ConcurrentHashMap<String,org.jfree.data.time.TimeSeries>rulesMaxChartprotected ConcurrentHashMap<String,org.jfree.data.time.TimeSeries>rulesMinChart-
Fields inherited from class org.droolsassert.RulesChronoAgendaEventListener
aggregationPeriodMs, rulesStat, sessionPrefix, usePackageName
-
-
Constructor Summary
Constructors Constructor Description RulesChronoChartRecorder()CreatesRulesChronoChartRecorderwith no session prefix and default aggregation periodRulesChronoChartRecorder(long aggregationPeriodMs)CreatesRulesChronoChartRecorderwith no session prefix and provided aggregation period
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jfree.data.time.TimeSeriesgetGlobalAvgChart()org.jfree.data.time.TimeSeriesgetGlobalMaxChart()org.jfree.data.time.TimeSeriesgetGlobalMinChart()TreeMap<String,org.jfree.data.time.TimeSeries>getRulesAvgChart()TreeMap<String,org.jfree.data.time.TimeSeries>getRulesMaxChart()TreeMap<String,org.jfree.data.time.TimeSeries>getRulesMinChart()booleanisRecordingStarted()protected voidrecordTimeSeries()voidreset()RulesChronoChartRecorderwithAvgThreshold(double threshold)Start gather chart data only if threshold value reachedRulesChronoChartRecorderwithDataTypes(RulesChronoChartRecorder.DataType... dataTypes)Per rule and global (generalized) chart data is gathered by defaultRulesChronoChartRecorderwithMaxThreshold(double threshold)Start gather chart data only if threshold value reachedRulesChronoChartRecorderwithMinThreshold(double threshold)Start gather chart data only if threshold value reachedRulesChronoChartRecorderwithPackageName(boolean usePackageName)Include rule package name to qualify rule name, false by defaultRulesChronoChartRecorderwithRetentionPeriod(long time, TimeUnit units)Retain last 3h chart data by defaultRulesChronoChartRecorderwithSessionPrefix(String sessionPrefix)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.-
Methods inherited from class org.droolsassert.RulesChronoAgendaEventListener
afterMatchFired, beforeMatchFired, getPerfStat
-
-
-
-
Field Detail
-
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 Detail
-
RulesChronoChartRecorder
public RulesChronoChartRecorder()
CreatesRulesChronoChartRecorderwith no session prefix and default aggregation period
-
RulesChronoChartRecorder
public RulesChronoChartRecorder(long aggregationPeriodMs)
CreatesRulesChronoChartRecorderwith no session prefix and provided aggregation period- Parameters:
aggregationPeriodMs-
-
-
Method Detail
-
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:RulesChronoAgendaEventListenerInclude rule package name to qualify rule name, false by default- Overrides:
withPackageNamein classRulesChronoAgendaEventListener
-
withSessionPrefix
public RulesChronoChartRecorder withSessionPrefix(String sessionPrefix)
Description copied from class:RulesChronoAgendaEventListenerInclude 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:
withSessionPrefixin classRulesChronoAgendaEventListener
-
recordTimeSeries
protected void recordTimeSeries()
-
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:
resetin classRulesChronoAgendaEventListener
-
-