Skip to content

Commit 045f0f5

Browse files
committed
fix: some health checks are always UP even when a counter hits limit #4018
1 parent 427c032 commit 045f0f5

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

app/src/main/java/io/apicurio/registry/metrics/health/liveness/PersistenceExceptionLivenessCheck.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package io.apicurio.registry.metrics.health.liveness;
22

3-
import jakarta.enterprise.context.ApplicationScoped;
4-
import jakarta.enterprise.inject.Default;
5-
import jakarta.inject.Inject;
6-
73
import io.apicurio.common.apps.config.Info;
84
import io.apicurio.registry.metrics.health.AbstractErrorCounterHealthCheck;
95
import jakarta.annotation.PostConstruct;
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.enterprise.inject.Default;
8+
import jakarta.inject.Inject;
109
import org.eclipse.microprofile.config.inject.ConfigProperty;
1110
import org.eclipse.microprofile.health.HealthCheck;
1211
import org.eclipse.microprofile.health.HealthCheckResponse;
@@ -67,7 +66,7 @@ public synchronized HealthCheckResponse call() {
6766
return HealthCheckResponse.builder()
6867
.name("PersistenceExceptionLivenessCheck")
6968
.withData("errorCount", errorCounter)
70-
.up()
69+
.status(up)
7170
.build();
7271
}
7372

app/src/main/java/io/apicurio/registry/metrics/health/liveness/ResponseErrorLivenessCheck.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package io.apicurio.registry.metrics.health.liveness;
22

3-
import jakarta.enterprise.context.ApplicationScoped;
4-
import jakarta.enterprise.inject.Default;
5-
import jakarta.inject.Inject;
6-
73
import io.apicurio.common.apps.config.Info;
84
import io.apicurio.registry.metrics.health.AbstractErrorCounterHealthCheck;
95
import jakarta.annotation.PostConstruct;
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.enterprise.inject.Default;
8+
import jakarta.inject.Inject;
109
import org.eclipse.microprofile.config.inject.ConfigProperty;
1110
import org.eclipse.microprofile.health.HealthCheck;
1211
import org.eclipse.microprofile.health.HealthCheckResponse;
@@ -65,7 +64,7 @@ public synchronized HealthCheckResponse call() {
6564
return HealthCheckResponse.builder()
6665
.name("ResponseErrorLivenessCheck")
6766
.withData("errorCount", errorCounter)
68-
.up()
67+
.status(up)
6968
.build();
7069
}
7170

app/src/main/java/io/apicurio/registry/metrics/health/readiness/PersistenceTimeoutReadinessCheck.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package io.apicurio.registry.metrics.health.readiness;
22

3-
import java.time.Duration;
4-
5-
import jakarta.enterprise.context.ApplicationScoped;
6-
import jakarta.enterprise.inject.Default;
7-
import jakarta.inject.Inject;
8-
93
import io.apicurio.common.apps.config.Info;
104
import io.apicurio.registry.metrics.health.AbstractErrorCounterHealthCheck;
115
import jakarta.annotation.PostConstruct;
6+
import jakarta.enterprise.context.ApplicationScoped;
7+
import jakarta.enterprise.inject.Default;
8+
import jakarta.inject.Inject;
129
import org.eclipse.microprofile.config.inject.ConfigProperty;
1310
import org.eclipse.microprofile.health.HealthCheck;
1411
import org.eclipse.microprofile.health.HealthCheckResponse;
1512
import org.eclipse.microprofile.health.Liveness;
1613
import org.slf4j.Logger;
1714

15+
import java.time.Duration;
16+
1817
/**
1918
* Fail readiness check if the duration of processing a artifactStore operation is too high.
2019
*
@@ -74,7 +73,7 @@ public synchronized HealthCheckResponse call() {
7473
return HealthCheckResponse.builder()
7574
.name("PersistenceTimeoutReadinessCheck")
7675
.withData("errorCount", errorCounter)
77-
.up()
76+
.status(up)
7877
.build();
7978
}
8079

app/src/main/java/io/apicurio/registry/metrics/health/readiness/ResponseTimeoutReadinessCheck.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
import io.apicurio.common.apps.config.Info;
44
import io.apicurio.registry.metrics.health.AbstractErrorCounterHealthCheck;
55
import jakarta.annotation.PostConstruct;
6-
import org.eclipse.microprofile.config.inject.ConfigProperty;
7-
import org.eclipse.microprofile.health.HealthCheck;
8-
import org.eclipse.microprofile.health.HealthCheckResponse;
9-
import org.eclipse.microprofile.health.Readiness;
10-
import org.slf4j.Logger;
11-
import java.time.Duration;
12-
import java.time.Instant;
13-
import java.time.format.DateTimeParseException;
146
import jakarta.enterprise.context.ApplicationScoped;
157
import jakarta.enterprise.inject.Default;
168
import jakarta.enterprise.inject.Instance;
@@ -20,6 +12,15 @@
2012
import jakarta.ws.rs.container.ContainerResponseContext;
2113
import jakarta.ws.rs.container.ContainerResponseFilter;
2214
import jakarta.ws.rs.ext.Provider;
15+
import org.eclipse.microprofile.config.inject.ConfigProperty;
16+
import org.eclipse.microprofile.health.HealthCheck;
17+
import org.eclipse.microprofile.health.HealthCheckResponse;
18+
import org.eclipse.microprofile.health.Readiness;
19+
import org.slf4j.Logger;
20+
21+
import java.time.Duration;
22+
import java.time.Instant;
23+
import java.time.format.DateTimeParseException;
2324

2425
/**
2526
* @author Jakub Senko <em>m@jsenko.net</em>
@@ -94,7 +95,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont
9495
log.error("Value '{}' of header '{}' is the wrong format!", requestStart, HEADER_NAME);
9596
}
9697

97-
} else if (responseContext.getStatus() != 404){
98+
} else if (responseContext.getStatus() != 404) {
9899
log.warn("Expected header '{}' not found.", HEADER_NAME);
99100
}
100101
}
@@ -105,7 +106,7 @@ public synchronized HealthCheckResponse call() {
105106
return HealthCheckResponse.builder()
106107
.name("ResponseTimeoutReadinessCheck")
107108
.withData("errorCount", errorCounter)
108-
.up()
109+
.status(up)
109110
.build();
110111
}
111112
}

0 commit comments

Comments
 (0)