Drools 8 RuleUnit and drools-metric/ReteDumper

19 views
Skip to first unread message

Andrew Menning

unread,
May 22, 2024, 6:54:20 PMMay 22
to Drools Usage
I am working on a project that currently uses drools 7 with mvel dialect and working on converting it to using RuleUnit in drools 8.  I have been able to use drools-metric with the tradition syntax/kieSession in drools 7 but how can I use RuleUnit with ReteDumper/drools-metric?

ReteDumper.dump needs a kbase, but I don't see that available from RuleUnitProvider, RuleUnitData or RuleUnitInstance.  

Thank you,
Andrew

Toshiya Kobayashi

unread,
May 23, 2024, 3:46:09 AMMay 23
to Drools Usage
Hi,

You can use ReteDumper like this

            ReteEvaluator evaluator = (ReteEvaluator)((ReteEvaluatorBasedRuleUnitInstance) unitInstance).getEvaluator();
            InternalRuleBase internalRuleBase = evaluator.getKnowledgeBase();
            ReteDumper.dumpRete(internalRuleBase);

drools-metric should work with RuleUnit in the same way as KieSession API. 
- Add dependency
- System.setProperty("drools.metric.logger.enabled", "true");
- <logger name="org.drools.metric.util.MetricLogUtils" level="trace"/>
- System.setProperty("drools.metric.logger.threshold", "0"); // default is 500 microsecond. "0" is helpful to check if drools-metric is working
- Note : drools-metric logs only for BetaNode (e.g. JoinNode). You can check with ReteDumper.dumpRete if your rules have JoinNode or not.

Regards,
Toshiya

2024年5月23日木曜日 7:54:20 UTC+9 Andrew Menning:
Reply all
Reply to author
Forward
0 new messages