forked from apache/incubator-kie-kogito-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix apache#3486] Add input param counter
- Loading branch information
Showing
8 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
kogito-serverless-workflow/kogito-serverless-workflow-monitoring/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-serverless-workflow</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>kogito-serverless-workflow-monitoring</artifactId> | ||
<name>Kogito :: Serverless Workflow :: Monitoring</name> | ||
<properties> | ||
<java.module.name>org.kie.kogito.serverless.workflow.monitoring</java.module.name> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-addons-monitoring-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-serverless-workflow-runtime</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
51 changes: 51 additions & 0 deletions
51
...a/org/kie/kogito/serverless/workflow/monitoring/SonataFlowMetricProcessEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.kie.kogito.serverless.workflow.monitoring; | ||
|
||
import org.kie.api.event.process.ProcessStartedEvent; | ||
import org.kie.kogito.KogitoGAV; | ||
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance; | ||
import org.kie.kogito.monitoring.core.common.process.MetricsProcessEventListener; | ||
import org.kie.kogito.serverless.workflow.SWFConstants; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.Tag; | ||
|
||
public class SonataFlowMetricProcessEventListener extends MetricsProcessEventListener { | ||
|
||
public SonataFlowMetricProcessEventListener(KogitoGAV gav, MeterRegistry meterRegistry) { | ||
super("sonataflow-process-monitoring-listener", gav, meterRegistry); | ||
} | ||
|
||
@Override | ||
public void afterProcessStarted(ProcessStartedEvent event) { | ||
super.afterProcessStarted(event); | ||
final KogitoProcessInstance processInstance = (KogitoProcessInstance) event.getProcessInstance(); | ||
Object node = processInstance.getVariables().get(SWFConstants.DEFAULT_WORKFLOW_VAR); | ||
if (node instanceof ObjectNode) { | ||
registerObject(processInstance.getProcessId(), (ObjectNode) node, null); | ||
} | ||
|
||
} | ||
|
||
private void registerObject(String processId, ObjectNode node, String prefix) { | ||
node.fields().forEachRemaining(e -> registerInputParam(processId, e.getKey(), e.getValue(), prefix)); | ||
} | ||
|
||
private void registerInputParam(String processId, String key, JsonNode value, String prefix) { | ||
if (value.isObject()) { | ||
registerObject(processId, (ObjectNode) value, concat(prefix, key)); | ||
} else { | ||
registerInputParam(processId, concat(prefix, key), value.toString()); | ||
} | ||
} | ||
|
||
private String concat(String prefix, String key) { | ||
return prefix == null ? key : prefix + "." + key; | ||
} | ||
|
||
private void registerInputParam(String processId, String key, String value) { | ||
buildCounter("sonataflow_input_parameters_counter", "Input parameters", processId, Tag.of("param_name", key), Tag.of("param_value", value)).increment(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-addons-quarkus-monitoring-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>kie-addons-quarkus-monitoring-sonataflow</artifactId> | ||
<name>KIE Add-On Monitoring Sonataflow</name> | ||
<properties> | ||
<java.module.name>org.kie.kogito.monitoring.sonataflow.quarkus</java.module.name> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-addons-quarkus-monitoring-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.kie.kogito</groupId> | ||
<artifactId>kogito-serverless-workflow-monitoring</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...low/src/main/java/org/kie/sonataflow/monitoring/SonataFlowMetricEventListenerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.kie.sonataflow.monitoring; | ||
|
||
import org.kie.kogito.KogitoGAV; | ||
import org.kie.kogito.config.ConfigBean; | ||
import org.kie.kogito.internal.process.event.KogitoProcessEventListener; | ||
import org.kie.kogito.monitoring.core.common.Constants; | ||
import org.kie.kogito.monitoring.core.common.process.MetricsProcessEventListener; | ||
import org.kie.kogito.serverless.workflow.monitoring.SonataFlowMetricProcessEventListener; | ||
|
||
import io.micrometer.core.instrument.Metrics; | ||
import io.quarkus.arc.properties.IfBuildProperty; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
|
||
public class SonataFlowMetricEventListenerFactory { | ||
|
||
@Inject | ||
ConfigBean configBean; | ||
|
||
@Produces | ||
public KogitoProcessEventListener produceProcessListener() { | ||
return new SonataFlowMetricProcessEventListener( | ||
configBean.getGav().orElse(KogitoGAV.EMPTY_GAV), Metrics.globalRegistry); | ||
} | ||
} | ||
|
1 change: 1 addition & 0 deletions
1
quarkus/addons/monitoring/sonataflow/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kogito.monitoring.process.useDefault=false |