Skip to content

Commit

Permalink
KOGITO-3828 - dmn-drools-metrics-quarkus example update (apache#458)
Browse files Browse the repository at this point in the history
* remove config listeners

* rename config property

* add process metrics test

* rename config property

* removed wrong file

* remove Interceptor

* update readme

* rename monitoring modules

* remove files
  • Loading branch information
r00ta authored Dec 11, 2020
1 parent 24aa92b commit 3100c6f
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 301 deletions.
27 changes: 7 additions & 20 deletions dmn-drools-quarkus-metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,20 @@ You will need:

### How to enable the feature

Import the following dependency in your `pom.xml`:
Import the following dependency in your `pom.xml` if you are using quarkus:

```XML
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
```

And add the following class in your quarkus project:

```Java
package org.kie.kogito.examples;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.ext.Provider;

import org.kie.addons.monitoring.system.interceptor.MetricsInterceptor;

@Provider
public class MyInterceptor extends MetricsInterceptor {
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
super.filter(requestContext, responseContext);
}
}
Otherwise, if you are using springboot import
```XML
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-springboot-addon</artifactId></dependency>
```

### Architecture
Expand Down
6 changes: 1 addition & 5 deletions dmn-drools-quarkus-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-core</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* 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.kie.kogito.examples;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;

@QuarkusTest
public class DroolsMetricsTest {

@Test
public void testDrlMetrics() {
given()
.body("{\"strings\": [\"hello\"]}")
.contentType(ContentType.JSON)
.when()
.post("/hello")
.then()
.statusCode(200);

given()
.when()
.get("/metrics")
.then()
.statusCode(200)
.body(containsString("drl_match_fired_nanosecond_count{app_id=\"default-rule-monitoring-listener\",process_id=\"helloWorld\",} 1.0"));
}
}
2 changes: 1 addition & 1 deletion kogito-travel-agency/basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion kogito-travel-agency/extended/travels/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package org.acme.travel;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand All @@ -26,6 +23,8 @@
import javax.inject.Inject;
import javax.inject.Named;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import org.acme.travels.Address;
import org.acme.travels.Flight;
import org.acme.travels.Hotel;
Expand All @@ -42,8 +41,10 @@
import org.kie.kogito.testcontainers.quarkus.InfinispanQuarkusTestResource;
import org.kie.kogito.testcontainers.quarkus.KafkaQuarkusTestResource;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import static io.restassured.RestAssured.given;
import static org.hamcrest.core.StringContains.containsString;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@QuarkusTest
@QuarkusTestResource(value = InfinispanQuarkusTestResource.class)
Expand Down Expand Up @@ -88,6 +89,17 @@ public void testTravelVisaRequired() {
thenProcessIsActive();
}

@Test
public void testProcessMetrics() {
whenNewTravel(TRAVELLER_FROM_POLAND, TRIP_TO_POLAND);
given()
.when()
.get("/metrics")
.then()
.statusCode(200)
.body(containsString("kie_process_instance_running_total{app_id=\"default-process-monitoring-listener\",process_id=\"travels\",} 1.0"));
}

private void whenNewTravel(Traveller traveller, Trip trip) {
Model m = travelsProcess.createModel();
Map<String, Object> parameters = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion kogito-travel-agency/extended/visas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.acme.travels.VisaApplication;
import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl;
import org.kie.api.event.process.ProcessCompletedEvent;
import org.kie.kogito.monitoring.core.MonitoringRegistry;
import org.kie.kogito.monitoring.prometheus.PrometheusRegistryProvider;
import org.kie.kogito.monitoring.prometheus.process.PrometheusProcessEventListener;
import org.kie.kogito.monitoring.core.common.MonitoringRegistry;
import org.kie.kogito.monitoring.prometheus.common.PrometheusRegistryProvider;
import org.kie.kogito.monitoring.prometheus.common.process.PrometheusProcessEventListener;

public class VisaApplicationPrometheusProcessEventListener extends PrometheusProcessEventListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ mp.messaging.outgoing.kogito-usertaskinstances-events.value.serializer=org.apach
mp.messaging.outgoing.kogito-variables-events.connector=smallrye-kafka
mp.messaging.outgoing.kogito-variables-events.topic=kogito-variables-events
mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer

kogito.monitoring.process.useDefault=false
2 changes: 1 addition & 1 deletion onboarding-example/hr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
<artifactId>monitoring-prometheus-addon</artifactId>
<artifactId>monitoring-prometheus-quarkus-addon</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Loading

0 comments on commit 3100c6f

Please sign in to comment.