rules-framework icon indicating copy to clipboard operation
rules-framework copied to clipboard

Record and report rules usage statistics

Open luispfgarces opened this issue 3 years ago • 0 comments

Purpose

Record usage of each rule and generate statistics, to help users assess the impact of specific rules on their usage scenarios.

Main functionalities

  • Record rules evaluation counters - per rule.
  • Record rules match counters - per rule, separate counters for match one and match many.
  • Generate parameterized statistics in tabular-like format.

Assume default time bucket for counters as 1 hour - but make it configurable. Make sure each time bucket records its' start date and time.

Proposal

Assume the record of evaluation and match counters to be created/updated on each evaluation done to RulesEngine. A internal Rules.Framework component for acting as listener should be designed and implemented to achieve this - design open for suggestions, leaving this without proposal for now.

Create a new method on RulesEngine to generate statistics in a tabular-like format - Statistics GenerateRulesUsageStatistics(GenerateRulesUsageStatisticsArgs generateStatisticsArgs):

  • Receive as parameter new value object GenerateRulesUsageStatisticsArgs:
    • Allow defining a time interval - DateBegin and DateEnd
      • Should we make time interval mandatory? If not mandatory, should we have a hard default defined (not configurable)?
      • Should we limit time interval range?
    • Allow filtering by content type - ContentType
    • Allow filtering for rule names set - RuleNames - an array of strings
    • Must define scope of statistics generation - Scope - an enum parameter:
      • Evaluation - generate statistics for rules evaluation
      • MatchOne - generate statistics for match one result rules
      • MatchMany - generate statistics for match many result rules
      • Match - generate statistics for all match types result rules
  • Return result in new object Statistics:
    • Must have a collection of StatisticsBucket:
      • Each StatisticsBucket includes:
        • Name to describe, in this case, which rule name the bucket refers to
        • A Timestamp to describe in time to when the bucket is reporting
        • And also a numeric Value to refer the bucket value - in this case it will be an integer, but it would be appropriate to use a decimal or a floating point type for future usage on other statistics use cases.
    • Should we group StatisticsBucket per name or per timestamp?
  • Must have a time interval - DateBegin and DateEnd

NOTE: proposal is open to debate and actual implementation plan is to be added later here.

luispfgarces avatar Nov 27 '21 18:11 luispfgarces