3737import jakarta .ws .rs .core .MediaType ;
3838import org .apache .commons .lang3 .StringUtils ;
3939import org .eclipse .microprofile .config .inject .ConfigProperty ;
40+ import org .eclipse .microprofile .openapi .annotations .Operation ;
4041import org .jboss .logging .Logger ;
4142
43+ /** Status and configuration verification for the application. */
4244@ Path ("" )
4345class Health {
4446
@@ -70,6 +72,15 @@ class Health {
7072 @ Blocking
7173 @ Path ("/health" )
7274 @ PermitAll
75+ @ Operation (
76+ summary = "Check the overall status of the application" ,
77+ description =
78+ """
79+ Returns a map indicating whether various external components (ex.
80+ jfr-datasource, grafana-dashboard) are configured and whether those
81+ components can be reached by the Cryostat application. Also includes
82+ application semantic version and build information.
83+ """ )
7384 public ApplicationHealth health () {
7485 CompletableFuture <Boolean > datasourceAvailable = new CompletableFuture <>();
7586 CompletableFuture <Boolean > dashboardAvailable = new CompletableFuture <>();
@@ -113,12 +124,31 @@ public ApplicationHealth health() {
113124 @ Blocking
114125 @ Path ("/health/liveness" )
115126 @ PermitAll
127+ @ Operation (
128+ summary = "Check if the application is able to accept and respond to requests." ,
129+ description =
130+ """
131+ Performs a no-op on a worker thread. This is a simply check to determine if
132+ the application has available threads to service requests. HTTP 204 No Content
133+ is the only expected response. If the application is not live and no worker
134+ threads are available, then the client will never receive a response.
135+ """ )
116136 public void liveness () {}
117137
118138 @ GET
119139 @ Path ("/api/v4/grafana_dashboard_url" )
120140 @ PermitAll
121141 @ Produces ({MediaType .APPLICATION_JSON })
142+ @ Operation (
143+ summary =
144+ "Return the URL which users can visit to access the associated Grafana"
145+ + " dashboard instance." ,
146+ description =
147+ """
148+ Returns the URL for the associated Grafana dashboard instance. If there is an internally-accessible
149+ (for Cryostat) URL and an externally-accessible URL (for users) URL, the externally-accessible URL
150+ is preferred. If neither are configured then the response is an HTTP 400 Bad Request.
151+ """ )
122152 public DashboardUrl grafanaDashboardUrl () {
123153 String url =
124154 dashboardExternalURL .orElseGet (
@@ -130,6 +160,14 @@ public DashboardUrl grafanaDashboardUrl() {
130160 @ Path ("/api/v4/grafana_datasource_url" )
131161 @ PermitAll
132162 @ Produces ({MediaType .APPLICATION_JSON })
163+ @ Operation (
164+ summary = "Return the URL to the associated jfr-datasource instance." ,
165+ description =
166+ """
167+ Returns the URL for the jfr-datasource instance which Cryostat is configured to use. This datasource
168+ accepts JFR file uploads from Cryostat and allows the Grafana dashboard to perform queries on the
169+ data within the recording file.
170+ """ )
133171 public DatasourceUrl grafanaDatasourceUrl () {
134172 String url = datasourceURL .orElseThrow (() -> new BadRequestException ());
135173 return new DatasourceUrl (url );
0 commit comments