From 508a12f8ca36f2afd52a8b810e4ff485ca3697da Mon Sep 17 00:00:00 2001 From: croway Date: Wed, 2 Sep 2026 16:17:38 +0200 Subject: [PATCH] CAMEL-24592: camel-microprofile-health - only expose health check stack traces in full exposure level CamelMicroProfileHealthHelper.applyHealthDetail added the full stack trace of a failed health check as error.stacktrace at every exposure level except oneline, so a DOWN check whose result carries an exception serialised the whole cause chain into the health response at the default level. error.stacktrace is now added only when the exposure level is full, matching the documented meaning of the levels, where full is the level that includes all details from the invoked health checks. error.message is still reported at the default level and the trace is unchanged in the application log. The same gating is applied to the Spring Boot actuator in camel-spring-boot so the runtimes stay aligned; Camel Quarkus builds its health responses through this module and inherits the change. Co-Authored-By: Claude Fable 5.1 --- .../health/CamelMicroProfileHealthHelper.java | 7 +++++-- .../health/CamelMicroProfileHealthCheckTest.java | 6 ++++-- .../ROOT/pages/camel-4x-upgrade-guide-4_23.adoc | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) 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