Skip to content

Commit 5eb93e7

Browse files
authored
Merge pull request #207 from sladkoff/bug/197
fix: Plugin crashes on Azul JVM
2 parents 61940e3 + ca66c81 commit 5eb93e7

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased] - 2024-01-02
9+
10+
Special thanks to all new and old contributors :star:
11+
12+
### Fixed
13+
- [#197](https://github.com/sladkoff/minecraft-prometheus-exporter/issues/197): Plugin crashes on Azul JVM
14+
15+
816
## [v2.5.0] - 2022-04-11
917

1018
Special thanks to all new and old contributors :star:

src/main/java/de/sldk/mc/config/PrometheusExporterConfig.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,22 @@ public void loadDefaultsAndSave() {
6161
public void enableConfiguredMetrics() {
6262
PrometheusExporterConfig.METRICS
6363
.forEach(metricConfig -> {
64-
Metric metric = metricConfig.getMetric(prometheusExporter);
65-
Boolean enabled = get(metricConfig);
64+
String metricName = metricConfig.getClass().getSimpleName();
65+
try {
66+
Metric metric = metricConfig.getMetric(prometheusExporter);
67+
Boolean enabled = get(metricConfig);
6668

67-
if (Boolean.TRUE.equals(enabled)) {
68-
metric.enable();
69-
}
69+
if (Boolean.TRUE.equals(enabled)) {
70+
metric.enable();
71+
}
7072

71-
prometheusExporter.getLogger().fine("Metric " + metric.getClass().getSimpleName() + " enabled: " + enabled);
73+
prometheusExporter.getLogger().fine("Metric " + metricName + " enabled: " + enabled);
7274

73-
MetricRegistry.getInstance().register(metric);
75+
MetricRegistry.getInstance().register(metric);
76+
} catch (Exception e) {
77+
prometheusExporter.getLogger().warning("Failed to enable metric " + metricName + ": " + e.getMessage());
78+
prometheusExporter.getLogger().log(java.util.logging.Level.FINE, "Failed to enable metric " + metricName, e);
79+
}
7480
});
7581
}
7682

0 commit comments

Comments
 (0)