◷ Reading Time: 4 minutes
Capturing
FlexRule Runtime is event-driven. That means you can capture details of what is happening during rules execution. Namespace FlexRule.Events have all related types for this behavior. There are two ways of capturing the events:
- Automatically (Using IRuntimeEngine.EnableFullLog)
- Manually (Using FlexRule.Events.RuntimeEvents)
Events
Here is the list of events that can be captured:
Name | When is raised? |
---|---|
CriteriaEvaluated | logic of a rule is evaluated |
RanActions | Actions of a rule are executed because the criteria are met |
RanAlternateActions | Actions of a rule are executed because the criteria are not met |
ConditionEvaluated | Condition of a rule is evaluated |
RunningReferencedLogic | Referenced logic of higher level is about to run |
CriteriaEvaluating | criteria of a rule is about to be evaluated |
Execution Log
When on RuntimeEngine.EnableFullLog is set to true, it captures all the events for execution. Then RuntimeResult.ConclusionLog can be used to retrieve a generated execution log based on raised events. Below is a sample of a conclusionLog:
Document: discount percentage R1 (Passed=False): Conditions (Count=1): [1] Destination: (Result=false) R2 (Passed=True): Conditions (Count=3): [1] Destination: (Result=true) [2] Age: (Result=true) [3] Is Friday or Monday: (Result=true) R3 (Passed=False): Conditions (Count=3): [1] Destination: (Result=true) [2] Age: (Result=true) [3] Is Firday or Monday: (Result=false) R4 (Passed=False): Conditions (Count=1): [1] Destination: (Result=false) R5 (Passed=False): Conditions (Count=1): [1] Destination: (Result=false) R6 (Passed=False): Conditions (Count=2): [1] Destination: (Result=true) [2] Age: (Result=false) R7 (Passed=False): Conditions (Count=2): [1] Destination: (Result=true) [2] Age: (Result=false)
Capturing Events
When you don’t need a full log, and you are just looking for some specific events, then RuntimeEngine.Events can be set manually to any of the events mentioned above. After execution is finished all of the events RuntimeResult.Events will have all the collected execution events:

Custom Build Reports
There might be a need to create custom reports based on specific layouts, and formats, etc. This can be done by creating applications and collecting Runtime execution events and finally, putting the events’ information back together as a report to present in the desired format or layout.
FlexRule Runtime provides a FlexRule.Events namespace to manage and access the events. Your application can subscribe to events using the RuntimeEvents.Register method, which allows registering for specific events.
The events can be aggregated to create custom reports. Events have a semantic relationship as a child-parent relationship. To understand and navigate this relationship, out-of-the-box the event aggregation is provided by Report Elements in FlexRule Runtime.
// eng is the instance of engine from RuntimeEngine
eng.EnableFullLog = true;
var result = eng.Run(new Dictionary<string, object>()
{
{"probList", probList},
{"car", car}
});
// Raw report for execution
var events = result.Events;
// Tree structure of events
var report = events.BuildEventsHierarchy().First();
var rules = report.Rules;
Performance Counter
Once the events are raise and captured, they can be used to create a performance tree to identify any bottlenecks.
You need to follow a two-step process from the events list:
- Building the events hierarchy using BuildEventsHierarchy
- Create the tree for the created Logic report object using
// creating the document logic report
var reportLogic = events.BuildEventsHierarchy().First();
// creating counter tree from logic report
var counter = logic.BuildPerformanceCounter();
