diff --git a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java index 4ab85f3543290..9af1cc0adc1ee 100644 --- a/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java +++ b/components/camel-microprofile/camel-microprofile-health/src/main/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthHelper.java @@ -60,8 +60,11 @@ public static void applyHealthDetail(HealthCheckResponseBuilder builder, Result result.getError().ifPresent(error -> { builder.withData("error.message", error.getMessage()); - final String s = ExceptionHelper.stackTraceToString(error); - builder.withData("error.stacktrace", s); + // the stack trace is the most verbose detail there is, so only expose it in the full level + if (exposureLevel.equals("full")) { + final String s = ExceptionHelper.stackTraceToString(error); + builder.withData("error.stacktrace", s); + } }); } } diff --git a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java index acb2459e2d9b4..1b6fb7ece8aeb 100644 --- a/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java +++ b/components/camel-microprofile/camel-microprofile-health/src/test/java/org/apache/camel/microprofile/health/CamelMicroProfileHealthCheckTest.java @@ -317,7 +317,8 @@ protected void doCall(HealthCheckResultBuilder builder, Map opti assertHealthCheckOutput("exception-check", Status.DOWN, checks.getJsonObject(0), jsonObject -> { assertEquals(errorMessage, jsonObject.getString("error.message")); - assertNotNull(jsonObject.getString("error.stacktrace")); + // the stack trace is only exposed in the full level + assertFalse(jsonObject.containsKey("error.stacktrace")); }); } @@ -359,7 +360,8 @@ protected void doCall(HealthCheckResultBuilder builder, Map opti assertHealthCheckOutput("failing-check", HealthCheckResponse.Status.DOWN, failedCheck, result -> { assertNotNull(result); assertEquals("Forced exception", result.getString("error.message")); - assertNotNull(result.getString("error.stacktrace")); + // the stack trace is only exposed in the full level + assertFalse(result.containsKey("error.stacktrace")); }); } diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc index 39ac96390335e..c37677941b5db 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_23.adoc @@ -1145,6 +1145,22 @@ A custom `CamelSagaService` that relies on the header to join sagas started by a override the new method. Everything else is unaffected: the header is still set on the exchange, and routes reading it continue to work. +=== camel-microprofile-health + +The `error.stacktrace` entry of a failed health check is now only included in the response when +`camel.health.exposure-level` is `full`. At the `default` level the check still reports `error.message`, but no +longer serialises the whole cause chain of the exception into the health response. The trace is unchanged in the +application log. + +This aligns the MicroProfile health output (and therefore Camel Quarkus, which builds its health responses through +this module) with the Spring Boot actuator and with the documented meaning of the levels, where `full` is the +level that includes all details from the invoked health checks. To get the trace back in the response: + +[source,properties] +---- +camel.health.exposure-level = full +---- + === camel-spring-boot A set of starter defaults changed in this release. Each is a deliberate change to what an application gets