Interface RuleStatisticsService
- All Known Implementing Classes:
RuleStatisticsServiceImpl
public interface RuleStatisticsService
Service for accessing rule execution statistics from the last x hours.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intControls how much history we keep in hours, should provide buffer for re-calculating previous rule_stat daily rollup (>= 25 hours) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled regularly to keep this table small.longgetActiveTenantCount(Environment env, Instant sinceTimeAgo) Returns count of tenants that executed a rule in the time period provided.getCurrentRuleExecutionStartTime(TenantContext context, long ruleId) Returns the current execution time prior the one with the provided audit log id.longgetExecutionTenantCount(TenantContext context, long millisAgo) Returns the number of times rules executed in timeframe specified on this tenant..intReturns the number of times rules executed in the current calendar month for a particular tenant.getLastRuleExecutionStates(TenantContext context, Set<Long> ruleIds) Retrieves the most recent rule execution states for the given rule ids.getPreviousRuleExecutionStartTime(TenantContext context, long ruleId) Returns the previous execution time prior the one with the provided audit log id.intgetQueuedItemCount(TenantContext context, long ruleId, long auditItemId) longgetQueuedItemCount(TenantContext context, Instant sinceTimeAgo) Get total queued items for tenant.getRuleStatistics(Environment environment, Instant sinceTimeAgo) Returns stats about rule executions since the time provided.longgetTotalExecutionDuration(TenantContext context, long millisAgo, long ruleId) Return the total duration this rule spent processing since the created OffsetTime.booleanhasAlreadyBegun(TenantContext context, AutomationEvent event, com.codebarrel.automation.api.config.RuleConfigBean rule) A check if the rule has already begun for this particular event? This will be accurate within the lastMAX_HISTORY_HOURShours.booleanisPreviousExecutionSuccessful(TenantContext context, long ruleId) Checks if the execution just prior to the one with the provided audit log id was successful.voidupdateStaleStatisticsEntries(TenantContext context, Set<Long> staleAuditItemIds) Updates the stale statistics entries for the given audit item ids.
-
Field Details
-
MAX_HISTORY_HOURS
static final int MAX_HISTORY_HOURSControls how much history we keep in hours, should provide buffer for re-calculating previous rule_stat daily rollup (>= 25 hours)- See Also:
-
-
Method Details
-
expireOldEntries
Called regularly to keep this table small.- Parameters:
env- the db environment
-
getExecutionTenantCount
Returns the number of times rules executed in timeframe specified on this tenant..- Parameters:
context- the tenant database contextmillisAgo- how long ago to look for executions in milliseconds- Returns:
- total count of rule executions
-
getExecutionTenantCountCurrentMonth
Returns the number of times rules executed in the current calendar month for a particular tenant.- Parameters:
context- the tenant database context- Returns:
- total count of rule executions
-
getTotalExecutionDuration
Return the total duration this rule spent processing since the created OffsetTime.- Parameters:
context- the tenant database contextmillisAgo- how long ago to look for executions in millisecondsruleId- the id of the rule to check- Returns:
- total execution time in milli seconds since the created offset
-
getLastRuleExecutionStates
Retrieves the most recent rule execution states for the given rule ids. This can be used to figure out if a rule currently has an error.- Parameters:
context- the tenant database contextruleIds- The rule ids to lookup audit items for.- Returns:
- set of matching rule execution states.
-
getPreviousRuleExecutionStartTime
Returns the previous execution time prior the one with the provided audit log id.- Parameters:
context- the tenant database contextruleId- The rule id to lookup the start time for- Returns:
- the start time or empty if the rule didn't execute yet.
-
getCurrentRuleExecutionStartTime
Returns the current execution time prior the one with the provided audit log id.- Parameters:
context- the tenant database contextruleId- The rule id to lookup the start time for- Returns:
- the start time or empty if the rule didn't execute yet.
-
isPreviousExecutionSuccessful
Checks if the execution just prior to the one with the provided audit log id was successful. Only returns false, if a previous execution was found that in an error state defined byState.isErrorState(String). If there was no prior execution this method returns true.- Parameters:
context- the tenant database contextruleId- The rule id to lookup the previous execution for
-
hasAlreadyBegun
boolean hasAlreadyBegun(TenantContext context, AutomationEvent event, com.codebarrel.automation.api.config.RuleConfigBean rule) A check if the rule has already begun for this particular event? This will be accurate within the lastMAX_HISTORY_HOURShours. -
getQueuedItemCount
-
getRuleStatistics
Returns stats about rule executions since the time provided.- Parameters:
sinceTimeAgo- duration for which to collect status- Returns:
- rule executions.
-
getQueuedItemCount
Get total queued items for tenant.- Parameters:
context- the tenantsinceTimeAgo- period for which to look up queued items- Returns:
- count of items
-
getActiveTenantCount
Returns count of tenants that executed a rule in the time period provided.- Parameters:
env- The tenant environment.sinceTimeAgo- period for which to look up active tenants (max 3 days).- Returns:
- count of active tenants.
-
updateStaleStatisticsEntries
Updates the stale statistics entries for the given audit item ids.- Parameters:
context- the tenant database contextstaleAuditItemIds- the set of stale audit item ids
-