Skip to content

Commit

Permalink
[incubator-kie-issues#1263] Enable conditional debug logging for jite…
Browse files Browse the repository at this point in the history
…xecutor-bpmn. (#2063)

Co-authored-by: Gabriele-Cardosi <[email protected]>
  • Loading branch information
gitgabrio and Gabriele-Cardosi authored May 27, 2024
1 parent d93023f commit ef4671f
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 13 deletions.
13 changes: 13 additions & 0 deletions jitexecutor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ run the generated application under `jitexecutor-runner/target/quarkus-app/` wit
java -jar jitexecutor-runner/target/quarkus-app/quarkus-run.jar
```

Log configuration
=================

Rest endpoints have log configuration to eventually print out received payload, if log is set to DEBUG level (default is INFO).
This is managed in the application.properties, that is under filtered-resources.
The `quarkus.log.category."org.kie.kogito".level` is set from `${jitexecutor.log.level}`, that by default is "INFO" in the pom.xml.

It can be overridden with commandline parameter, e.g.

```bash
mvn clean package -Djitexecutor.log.level=DEBUG
```

DMN
===

Expand Down
29 changes: 29 additions & 0 deletions jitexecutor/jitexecutor-bpmn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
# Kogito JIT BPMN Executor

## Log configuration

Rest endpoints have log configuration to eventually print out received payload, if log is set to DEBUG level (default is INFO).
This is managed in the application.properties, that is under filtered-resources.
The `quarkus.log.category."org.kie.kogito".level` is set from `${jitexecutor.log.level}`, that by default is "INFO" in the pom.xml.

It can be overridden with commandline parameter, e.g.

`mvn clean package -Djitexecutor.log.level=DEBUG`
27 changes: 27 additions & 0 deletions jitexecutor/jitexecutor-bpmn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<properties>
<java.module.name>org.kie.kogito.jitexecutor.bpmn</java.module.name>
<jitexecutor.log.level>INFO</jitexecutor.log.level>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -88,4 +89,30 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-filtered-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/filtered-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@

# quarkus.log.category."org".level=INFO

quarkus.log.category."org.kie.kogito".level=${jitexecutor.log.level}

# To avoid errors such as:
# Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: (full_name_of_the_class). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing type is then reported at run time when it is accessed the first time.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.kie.kogito.jitexecutor.bpmn.JITBPMNService;
import org.kie.kogito.jitexecutor.bpmn.responses.JITBPMNValidationResult;
import org.kie.kogito.jitexecutor.common.requests.MultipleResourcesPayload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jakarta.inject.Inject;
import jakarta.ws.rs.Consumes;
Expand All @@ -30,16 +32,24 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import static org.kie.kogito.jitexecutor.common.Constants.LINEBREAK;

@Path("jitbpmn/validate")
public class BPMNValidationResource {

private static final Logger LOGGER = LoggerFactory.getLogger(BPMNValidationResource.class);

@Inject
JITBPMNService jitbpmnService;

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response schema(MultipleResourcesPayload payload) {
LOGGER.debug(LINEBREAK);
LOGGER.debug("jitbpmn/validate");
LOGGER.debug(payload.toString());
LOGGER.debug(LINEBREAK);
JITBPMNValidationResult result = jitbpmnService.validatePayload(payload);
return Response.ok(result.getErrors()).build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.jitexecutor.common;

public class Constants {

public static final String LINEBREAK = "******\n";

private Constants() {
}
}
4 changes: 2 additions & 2 deletions jitexecutor/jitexecutor-dmn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

Rest endpoints have log configuration to eventually print out received payload, if log is set to DEBUG level (default is INFO).
This is managed in the application.properties, that is under filtered-resources.
The `quarkus.log.category."org.kie.kogito".level` is set from `${jitexecutor.dmn.log.level}`, that by default is "INFO" in the pom.xml.
The `quarkus.log.category."org.kie.kogito".level` is set from `${jitexecutor.log.level}`, that by default is "INFO" in the pom.xml.

It can be overridden with commandline parameter, e.g.

`mvn clean package -Djitexecutor.dmn.log.level=DEBUG`
`mvn clean package -Djitexecutor.log.level=DEBUG`
2 changes: 1 addition & 1 deletion jitexecutor/jitexecutor-dmn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<properties>
<java.module.name>org.kie.kogito.jitexecutor.dmn</java.module.name>
<jitexecutor.dmn.log.level>INFO</jitexecutor.dmn.log.level>
<jitexecutor.log.level>INFO</jitexecutor.log.level>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# quarkus.log.category."org".level=INFO

quarkus.log.category."org.kie.kogito".level=${jitexecutor.dmn.log.level}
quarkus.log.category."org.kie.kogito".level=${jitexecutor.log.level}

# To avoid errors such as:
# Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: org.kie.pmml.pmml_4_2.PMMLRequestDataBuilder. To diagnose the issue you can use the --allow-incomplete-classpath option. The missing type is then reported at run time when it is accessed the first time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import static org.kie.kogito.jitexecutor.common.Constants.LINEBREAK;

@Path("jitdmn/validate")
public class DMNValidationResource {

private static final Logger LOGGER = LoggerFactory.getLogger(DMNValidationResource.class);

static final String LINEBREAK = "******\n";

// trick for resolver/implementation for NI
static final DMNValidator validator = DMNValidatorFactory.newValidator(List.of(new ExtendedDMNProfile()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import static org.kie.kogito.jitexecutor.dmn.api.DMNValidationResource.LINEBREAK;
import static org.kie.kogito.jitexecutor.common.Constants.LINEBREAK;

@Path("/jitdmn")
public class JITDMNResource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.kie.dmn.openapi.model.DMNOASResult;
import org.kie.kogito.jitexecutor.common.requests.MultipleResourcesPayload;
import org.kie.kogito.jitexecutor.dmn.DMNEvaluator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -46,9 +48,13 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import static org.kie.kogito.jitexecutor.common.Constants.LINEBREAK;

@Path("jitdmn/schema")
public class SchemaResource {

private static final Logger LOGGER = LoggerFactory.getLogger(SchemaResource.class);

// trick for resolver/implementation for NI
static final OpenAPI x;
static Schema resourceWithURI;
Expand All @@ -65,6 +71,10 @@ public class SchemaResource {
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_JSON)
public Response schema(String payload) {
LOGGER.debug(LINEBREAK);
LOGGER.debug("jitdmn/validate");
LOGGER.debug(payload);
LOGGER.debug(LINEBREAK);
DMNModel dmnModel = DMNEvaluator.fromXML(payload).getDmnModel();
DMNOASResult oasResult = DMNOASGeneratorFactory.generator(Collections.singletonList(dmnModel)).build();
return fullSchema(dmnModel, oasResult, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void collectionTypeConstraintSucceed() throws IOException {
Map<String, Object> context =
Map.of("p1", Map.of("Name", "P3", "Interests", Arrays.asList("Ski")));
JITDMNPayload jitdmnpayload = new JITDMNPayload(modelRef, List.of(model),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand All @@ -97,7 +97,7 @@ void collectionTypeConstraintFails() throws IOException {
Map<String, Object> context =
Map.of("p1", Map.of("Name", "P3", "Interests", Arrays.asList("Ski", "Golf")));
JITDMNPayload jitdmnpayload = new JITDMNPayload(modelRef, List.of(model),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand All @@ -114,7 +114,7 @@ void collectionAllowedValuesSucceed() throws IOException {
Map<String, Object> context =
Map.of("p1", Map.of("Name", "P3", "Interests", Arrays.asList("Golf")));
JITDMNPayload jitdmnpayload = new JITDMNPayload(modelRef, List.of(model),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand All @@ -126,7 +126,7 @@ void collectionAllowedValuesSucceed() throws IOException {
context =
Map.of("p1", Map.of("Name", "P3", "Interests", Arrays.asList("Golf", "Jogging")));
jitdmnpayload = new JITDMNPayload(modelRef, List.of(model),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand All @@ -143,7 +143,7 @@ void collectionAllowedValuesFails() throws IOException {
Map<String, Object> context =
Map.of("p1", Map.of("Name", "P3", "Interests", Arrays.asList("Ski")));
JITDMNPayload jitdmnpayload = new JITDMNPayload(modelRef, List.of(model),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand Down Expand Up @@ -213,7 +213,7 @@ private void commonUnnamedImport(String importingModelRef, String importedModelR
Map<String, Object> context =
Map.of("A Person", Map.of("name", "John", "age", 47));
JITDMNPayload jitdmnpayload = new JITDMNPayload(importingModelRef, List.of(model1, model2),
context);
context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand Down

0 comments on commit ef4671f

Please sign in to comment.