From 674d3dd2620a3ce76b8b344210cb03fc9488cd24 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 9 Sep 2019 10:21:58 +0100 Subject: [PATCH] Polish health endpoint documentation for groups and nesting Closes gh-14022 --- .../src/main/asciidoc/endpoints/health.adoc | 26 ++++++++++++------- .../HealthEndpointDocumentationTests.java | 9 +++---- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/health.adoc b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/health.adoc index 1271af2a65..600b51f3f2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/health.adoc +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/asciidoc/endpoints/health.adoc @@ -29,8 +29,9 @@ include::{snippets}health/response-fields.adoc[] [[health-retrieving-component]] == Retrieving the Health of a component -To retrieve the health of a particular component of the application, make a `GET` request -to `/actuator/health/\{component}`, as shown in the following curl-based example: +To retrieve the health of a particular component of the application's health, make a +`GET` request to `/actuator/health/\{component}`, as shown in the following curl-based +example: include::{snippets}health/component/curl-request.adoc[] @@ -42,20 +43,20 @@ include::{snippets}health/component/http-response.adoc[] [[health-retrieving-component-response-structure]] === Response Structure -The response contains details of the health of a particular component of the application. -The following table describes the structure of the response: +The response contains details of the health of a particular component of the +application's health. The following table describes the structure of the response: [cols="2,1,3"] include::{snippets}health/component/response-fields.adoc[] -[[health-retrieving-component-instance]] -== Retrieving the Health of a component instance -If a particular component consists of multiple instances (as the `broker` indicator in -the example above), the health of a particular instance of that component can be retrieved -by issuing a `GET` request to `/actuator/health/\{component}/\{instance}`, as shown in the -following curl-based example: +[[health-retrieving-component-nested]] +== Retrieving the Health of a nested component +If a particular component contains other nested components (as the `broker` indicator in +the example above), the health of such a nested component can be retrieved by issuing a +`GET` request to `/actuator/health/\{component}/\{subcomponent}`, as shown in the following +curl-based example: include::{snippets}health/instance/curl-request.adoc[] @@ -63,6 +64,11 @@ The resulting response is similar to the following: include::{snippets}health/instance/http-response.adoc[] +Components of an application's health may be nested arbitrarily deep depending on the +application's health indicators and how they have been grouped. The health endpoint +supports any number of `/\{component}` identifiers in the URL to allow the health of a +component at any depth to be retrieved. + [[health-retrieving-component-instance-response-structure]] diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java index 028f120155..b097ba58bf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java @@ -78,12 +78,11 @@ class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentationTests .description("Status of a specific part of the application."); FieldDescriptor componentDetails = subsectionWithPath("details.*.details") .description("Details of the health of a specific part of the application. " - + "Presence is controlled by `management.endpoint.health.show-details`.") + + "Presence is controlled by `management.endpoint.health.show-details`. May contain nested " + + "components that make up the health.") .optional(); - FieldDescriptor nestedComponents = subsectionWithPath("details.*.details") - .description("Nested components that make up the health.").optional(); - this.mockMvc.perform(get("/actuator/health")).andExpect(status().isOk()).andDo(document("health", - responseFields(status, components, componentStatus, componentDetails, nestedComponents))); + this.mockMvc.perform(get("/actuator/health")).andExpect(status().isOk()) + .andDo(document("health", responseFields(status, components, componentStatus, componentDetails))); } @Test