From 3e60b142e524319598542bdabdfd96d5b0e516ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 17:48:15 +0200 Subject: [PATCH 1/7] feat(observability): add RuleEngineMetrics for rule evaluation latency and condition matching - firefly.ruleengine.evaluations (tagged rule.id, result), firefly.ruleengine.evaluation.duration (per-rule timer), firefly.ruleengine.conditions.matched, firefly.ruleengine.compilations, firefly.ruleengine.errors - timedEvaluation wrapper for production rule execution paths --- .../core/observability/RuleEngineMetrics.java | 71 +++++++++++++++++++ ...eEngineObservabilityAutoConfiguration.java | 42 +++++++++++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + 3 files changed, 114 insertions(+) create mode 100644 fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineMetrics.java create mode 100644 fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineObservabilityAutoConfiguration.java diff --git a/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineMetrics.java b/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineMetrics.java new file mode 100644 index 0000000..89855c0 --- /dev/null +++ b/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineMetrics.java @@ -0,0 +1,71 @@ +/* + * Copyright 2024-2026 Firefly Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.fireflyframework.rules.core.observability; + +import io.micrometer.core.instrument.MeterRegistry; +import org.fireflyframework.observability.metrics.FireflyMetricsSupport; +import reactor.core.publisher.Mono; + +/** + * Observability instrumentation for the Firefly rule engine. + *

+ * Records: + *

+ */ +public class RuleEngineMetrics extends FireflyMetricsSupport { + + private static final String TAG_RULE_ID = "rule.id"; + private static final String TAG_CONDITION_ID = "condition.id"; + private static final String TAG_RESULT = "result"; + + public RuleEngineMetrics(MeterRegistry meterRegistry) { + super(meterRegistry, "ruleengine"); + } + + public Mono timedEvaluation(String ruleId, Mono evaluation) { + return timed("evaluation.duration", evaluation, TAG_RULE_ID, ruleId) + .doOnSuccess(v -> counter("evaluations", + TAG_RULE_ID, ruleId, TAG_RESULT, "matched").increment()) + .doOnError(e -> { + counter("evaluations", TAG_RULE_ID, ruleId, TAG_RESULT, "error").increment(); + recordFailure("errors", e, TAG_RULE_ID, ruleId); + }); + } + + public void recordUnmatched(String ruleId) { + counter("evaluations", TAG_RULE_ID, ruleId, TAG_RESULT, "unmatched").increment(); + } + + public void recordConditionMatched(String ruleId, String conditionId) { + counter("conditions.matched", TAG_RULE_ID, ruleId, TAG_CONDITION_ID, conditionId).increment(); + } + + public void recordCompilation(boolean success) { + counter("compilations", "status", success ? "success" : "failure").increment(); + } +} diff --git a/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineObservabilityAutoConfiguration.java b/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineObservabilityAutoConfiguration.java new file mode 100644 index 0000000..e2c18f1 --- /dev/null +++ b/fireflyframework-rule-engine-core/src/main/java/org/fireflyframework/rules/core/observability/RuleEngineObservabilityAutoConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright 2024-2026 Firefly Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.fireflyframework.rules.core.observability; + +import io.micrometer.core.instrument.MeterRegistry; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; + +/** + * Auto-configures {@link RuleEngineMetrics} as a Spring bean. + */ +@AutoConfiguration +@ConditionalOnClass(MeterRegistry.class) +@ConditionalOnProperty(prefix = "firefly.observability.metrics", name = "enabled", + havingValue = "true", matchIfMissing = true) +public class RuleEngineObservabilityAutoConfiguration { + + @Bean + @ConditionalOnMissingBean + @ConditionalOnBean(MeterRegistry.class) + RuleEngineMetrics ruleEngineMetrics(MeterRegistry meterRegistry) { + return new RuleEngineMetrics(meterRegistry); + } +} diff --git a/fireflyframework-rule-engine-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/fireflyframework-rule-engine-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 517593c..4da25cc 100644 --- a/fireflyframework-rule-engine-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/fireflyframework-rule-engine-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ org.fireflyframework.rules.core.config.RuleEngineCacheAutoConfiguration +org.fireflyframework.rules.core.observability.RuleEngineObservabilityAutoConfiguration From 309478f8cb0ec58c4cd78775471b5bec1ab2c5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 17:57:09 +0200 Subject: [PATCH 2/7] release: bump version to 26.05.01 --- fireflyframework-rule-engine-core/pom.xml | 2 +- fireflyframework-rule-engine-interfaces/pom.xml | 2 +- fireflyframework-rule-engine-models/pom.xml | 2 +- fireflyframework-rule-engine-sdk/pom.xml | 2 +- fireflyframework-rule-engine-web/pom.xml | 2 +- pom.xml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fireflyframework-rule-engine-core/pom.xml b/fireflyframework-rule-engine-core/pom.xml index 4697e8b..55ff696 100644 --- a/fireflyframework-rule-engine-core/pom.xml +++ b/fireflyframework-rule-engine-core/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 fireflyframework-rule-engine-core diff --git a/fireflyframework-rule-engine-interfaces/pom.xml b/fireflyframework-rule-engine-interfaces/pom.xml index e544cab..40ab003 100644 --- a/fireflyframework-rule-engine-interfaces/pom.xml +++ b/fireflyframework-rule-engine-interfaces/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 fireflyframework-rule-engine-interfaces diff --git a/fireflyframework-rule-engine-models/pom.xml b/fireflyframework-rule-engine-models/pom.xml index 8354fc6..e3ada1d 100644 --- a/fireflyframework-rule-engine-models/pom.xml +++ b/fireflyframework-rule-engine-models/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 fireflyframework-rule-engine-models diff --git a/fireflyframework-rule-engine-sdk/pom.xml b/fireflyframework-rule-engine-sdk/pom.xml index aa0d202..45390ce 100644 --- a/fireflyframework-rule-engine-sdk/pom.xml +++ b/fireflyframework-rule-engine-sdk/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 fireflyframework-rule-engine-sdk diff --git a/fireflyframework-rule-engine-web/pom.xml b/fireflyframework-rule-engine-web/pom.xml index 3e5b003..5441098 100644 --- a/fireflyframework-rule-engine-web/pom.xml +++ b/fireflyframework-rule-engine-web/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 fireflyframework-rule-engine-web diff --git a/pom.xml b/pom.xml index cbd1e11..b3d6031 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,13 @@ org.fireflyframework fireflyframework-parent - 26.04.01 + 26.05.01 org.fireflyframework fireflyframework-rule-engine - 26.04.01 + 26.05.01 pom Firefly Framework - Rule Engine Library From 9fe6b706f73a29c93b1a282ea901d4a4840df6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 18:17:46 +0200 Subject: [PATCH 3/7] release: bump version to 26.05.06 --- fireflyframework-rule-engine-core/pom.xml | 2 +- fireflyframework-rule-engine-interfaces/pom.xml | 2 +- fireflyframework-rule-engine-models/pom.xml | 2 +- fireflyframework-rule-engine-sdk/pom.xml | 2 +- fireflyframework-rule-engine-web/pom.xml | 2 +- pom.xml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fireflyframework-rule-engine-core/pom.xml b/fireflyframework-rule-engine-core/pom.xml index 55ff696..a5af6d9 100644 --- a/fireflyframework-rule-engine-core/pom.xml +++ b/fireflyframework-rule-engine-core/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 fireflyframework-rule-engine-core diff --git a/fireflyframework-rule-engine-interfaces/pom.xml b/fireflyframework-rule-engine-interfaces/pom.xml index 40ab003..1706b9f 100644 --- a/fireflyframework-rule-engine-interfaces/pom.xml +++ b/fireflyframework-rule-engine-interfaces/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 fireflyframework-rule-engine-interfaces diff --git a/fireflyframework-rule-engine-models/pom.xml b/fireflyframework-rule-engine-models/pom.xml index e3ada1d..587af91 100644 --- a/fireflyframework-rule-engine-models/pom.xml +++ b/fireflyframework-rule-engine-models/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 fireflyframework-rule-engine-models diff --git a/fireflyframework-rule-engine-sdk/pom.xml b/fireflyframework-rule-engine-sdk/pom.xml index 45390ce..0e0a5b9 100644 --- a/fireflyframework-rule-engine-sdk/pom.xml +++ b/fireflyframework-rule-engine-sdk/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 fireflyframework-rule-engine-sdk diff --git a/fireflyframework-rule-engine-web/pom.xml b/fireflyframework-rule-engine-web/pom.xml index 5441098..9af6f59 100644 --- a/fireflyframework-rule-engine-web/pom.xml +++ b/fireflyframework-rule-engine-web/pom.xml @@ -6,7 +6,7 @@ org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 fireflyframework-rule-engine-web diff --git a/pom.xml b/pom.xml index b3d6031..02db30c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,13 +7,13 @@ org.fireflyframework fireflyframework-parent - 26.05.01 + 26.05.06 org.fireflyframework fireflyframework-rule-engine - 26.05.01 + 26.05.06 pom Firefly Framework - Rule Engine Library From 80bacb98d941bd798b8d5192e9623b61eb9f28e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 19:00:00 +0200 Subject: [PATCH 4/7] ci: re-trigger after layer 2 publish From 59c6d39475615de470a596b61161f11ece83ba5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 19:29:47 +0200 Subject: [PATCH 5/7] ci: re-trigger after layer 4 deps published From 7c924d52ba1554c3a428208a209b4845419371f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 19:36:00 +0200 Subject: [PATCH 6/7] ci: re-trigger after starter-core publish From 22c53789305cb0267fb2418468639bf57e279720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Contreras=20Guill=C3=A9n?= Date: Tue, 19 May 2026 19:36:08 +0200 Subject: [PATCH 7/7] ci: re-trigger after starter-core publish