mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-11 05:41:52 +01:00
[metrics] Catch any Throwable during initialization (#2480)
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
This commit is contained in:
parent
ff2f90684f
commit
c2a41549c0
@ -83,6 +83,7 @@ public class DefaultMetricsRegistration implements ReadyService.ReadyTracker, Me
|
||||
}
|
||||
|
||||
private void registerMeters() {
|
||||
try {
|
||||
logger.debug("Registering meters...");
|
||||
Set<Tag> tags = Set.of(OH_CORE_METRIC_TAG);
|
||||
meters.add(new JVMMetric(tags));
|
||||
@ -94,10 +95,19 @@ public class DefaultMetricsRegistration implements ReadyService.ReadyTracker, Me
|
||||
meters.add(new ThreadPoolMetric(tags));
|
||||
|
||||
meters.forEach(m -> m.bindTo(registry));
|
||||
} catch (Throwable e) {
|
||||
// handle exceptions gracefully to not break StartLevelService run
|
||||
logger.error("Exception caught during meter registration", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void unregisterMeters() {
|
||||
this.meters.forEach(OpenhabCoreMeterBinder::unbind);
|
||||
try {
|
||||
meters.forEach(OpenhabCoreMeterBinder::unbind);
|
||||
} catch (Throwable e) {
|
||||
// handle exceptions gracefully to not break StartLevelService run
|
||||
logger.error("Exception caught during meter de-registration", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user