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
Collect live performance statistic for rules (then block) as aggregated result and jfree chart
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.
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jfree.data.time.TimeSeriesprotected org.jfree.data.time.TimeSeriesprotected org.jfree.data.time.TimeSeriesstatic final intprotected longprotected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> protected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> protected final ConcurrentHashMap<String,org.jfree.data.time.TimeSeries> Fields inherited from class org.droolsassert.RulesChronoAgendaEventListener
aggregationPeriodMs, rulesStat, sessionPrefix, usePackageName -
Constructor Summary
ConstructorsConstructorDescriptionCreatesRulesChronoChartRecorderwith no session prefix and default aggregation periodRulesChronoChartRecorder(long aggregationPeriodMs) CreatesRulesChronoChartRecorderwith no session prefix and provided aggregation period -
Method Summary
Modifier and TypeMethodDescriptionorg.jfree.data.time.TimeSeriesorg.jfree.data.time.TimeSeriesorg.jfree.data.time.TimeSeriesbooleanprotected voidvoidreset()withAvgThreshold(double threshold) Start gather chart data only if threshold value reachedwithDataTypes(RulesChronoChartRecorder.DataType... dataTypes) Per rule and global (generalized) chart data is gathered by defaultwithMaxThreshold(double threshold) Start gather chart data only if threshold value reachedwithMinThreshold(double threshold) Start gather chart data only if threshold value reachedwithPackageName(boolean usePackageName) Include rule package name to qualify rule name, false by defaultwithRetentionPeriod(long time, TimeUnit units) Retain last 3h chart data by defaultwithSessionPrefix(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, getPerfStatMethods inherited from class org.kie.api.event.rule.DefaultAgendaEventListener
afterRuleFlowGroupActivated, afterRuleFlowGroupDeactivated, agendaGroupPopped, agendaGroupPushed, beforeRuleFlowGroupActivated, beforeRuleFlowGroupDeactivated, matchCancelled, matchCreated
-
Field Details
-
RETENTION_PERIOD_MIN
public static final int RETENTION_PERIOD_MIN -
rulesMaxChart
-
rulesAvgChart
-
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()CreatesRulesChronoChartRecorderwith no session prefix and default aggregation period -
RulesChronoChartRecorder
public RulesChronoChartRecorder(long aggregationPeriodMs) CreatesRulesChronoChartRecorderwith no session prefix and provided aggregation period- Parameters:
aggregationPeriodMs-
-
-
Method Details
-
withRetentionPeriod
Retain last 3h chart data by default -
withDataTypes
Per rule and global (generalized) chart data is gathered by default -
withMaxThreshold
Start gather chart data only if threshold value reached -
withAvgThreshold
Start gather chart data only if threshold value reached -
withMinThreshold
Start gather chart data only if threshold value reached -
withPackageName
Description copied from class:RulesChronoAgendaEventListenerInclude rule package name to qualify rule name, false by default- Overrides:
withPackageNamein classRulesChronoAgendaEventListener
-
withSessionPrefix
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() -
getRulesMaxChart
-
getRulesAvgChart
-
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:
resetin classRulesChronoAgendaEventListener
-