Skip to content

Commit f63fe8a

Browse files
committed
docs: describe how to implement custom health checks
1 parent 3434d9a commit f63fe8a

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,37 @@ public class MyPluginCommand extends PluginCommand {
234234

235235
You can easily collect metrics about your own plugin.
236236

237-
[//]: # (TODO: Add a section about how to provide a health check from your own plugin.)
237+
#### Add compile-time dependency to your plugin
238+
239+
1. Get the latest `minecraft-prometheus-exporter-3.0.0.jar` from the [releases](https://github.com/sladkoff/minecraft-prometheus-exporter/releases) page.
240+
2. Add the jar to your project's classpath.
241+
242+
#### Create a health check
243+
244+
Create your custom health check by extending the `HealthCheck` class.
245+
246+
```java
247+
public class CustomHealthCheck implements HealthCheck {
248+
@Override
249+
public boolean isHealthy() {
250+
return true; // Your custom health check logic
251+
}
252+
}
253+
```
254+
255+
#### Create a health check
256+
257+
Register your health check in your plugin's `onEnable` method or similar.
258+
259+
This will add your health check to the list of health checks that are aggregated and exposed by the Minecraft Prometheus Exporter
260+
261+
```java
262+
public class MyPlugin extends JavaPlugin {
263+
264+
@Override
265+
public void onEnable() {
266+
// Register your health check
267+
getServer().servicesManager.load(HealthChecks.class).add(new CustomHealthCheck());
268+
}
269+
}
270+
```

0 commit comments

Comments
 (0)