Skip to content

Commit 2991f90

Browse files
committed
Drop the health check singleton methods.
1 parent bce36de commit 2991f90

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

metrics-core/src/main/java/com/yammer/metrics/HealthChecks.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
11
package com.yammer.metrics;
22

3-
import com.yammer.metrics.core.HealthCheck;
4-
import com.yammer.metrics.core.HealthCheck.Result;
53
import com.yammer.metrics.core.HealthCheckRegistry;
64

7-
import java.util.Map;
8-
95
/**
10-
* A manager class for health checks.
6+
* A default health check registry.
117
*/
128
public class HealthChecks {
139
private static final HealthCheckRegistry DEFAULT_REGISTRY = new HealthCheckRegistry();
1410

1511
private HealthChecks() { /* unused */ }
1612

17-
/**
18-
* Registers an application {@link HealthCheck} with a given name.
19-
*
20-
* @param healthCheck the {@link HealthCheck} instance
21-
*/
22-
public static void register(HealthCheck healthCheck) {
23-
DEFAULT_REGISTRY.register(healthCheck);
24-
}
25-
26-
/**
27-
* Runs the registered health checks and returns a map of the results.
28-
*
29-
* @return a map of the health check results
30-
*/
31-
public static Map<String, Result> runHealthChecks() {
32-
return DEFAULT_REGISTRY.runHealthChecks();
33-
}
34-
3513
/**
3614
* Returns the (static) default registry.
3715
*

metrics-core/src/test/java/com/yammer/metrics/tests/HealthChecksTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
import java.util.Map;
1010

11-
import static org.hamcrest.Matchers.instanceOf;
1211
import static org.hamcrest.Matchers.is;
1312
import static org.junit.Assert.assertThat;
1413

1514
public class HealthChecksTest {
15+
private final HealthCheckRegistry registry = HealthChecks.defaultRegistry();
16+
1617
private static class ExampleHealthCheck extends HealthCheck {
1718
private ExampleHealthCheck() {
1819
super("example");
@@ -26,20 +27,14 @@ protected Result check() throws Exception {
2627

2728
@Before
2829
public void setUp() throws Exception {
29-
HealthChecks.register(new ExampleHealthCheck());
30+
registry.register(new ExampleHealthCheck());
3031
}
3132

3233
@Test
3334
public void runsRegisteredHealthChecks() throws Exception {
34-
final Map<String, HealthCheck.Result> results = HealthChecks.runHealthChecks();
35+
final Map<String, HealthCheck.Result> results = registry.runHealthChecks();
3536

3637
assertThat(results.get("example"),
3738
is(HealthCheck.Result.healthy("whee")));
3839
}
39-
40-
@Test
41-
public void hasADefaultRegistry() throws Exception {
42-
assertThat(HealthChecks.defaultRegistry(),
43-
is(instanceOf(HealthCheckRegistry.class)));
44-
}
4540
}

0 commit comments

Comments
 (0)