Update metrics publisher hostname when hostname is changed (#2008)

This commit is contained in:
Sam Freund
2025-07-22 18:56:32 -05:00
committed by GitHub
parent 02e6b6d3e2
commit 758fbb9110

View File

@@ -244,6 +244,19 @@ public class MetricsManager {
public void publishMetrics() {
logger.debug("Publishing Metrics...");
// Check that the hostname hasn't changed
if (!metricPublisher.getTopic().getName().equals(CameraServerJNI.getHostname())) {
logger.warn("Metrics publisher name does not match hostname! Reinitializing publisher...");
metricPublisher.close();
metricPublisher =
NetworkTablesManager.getInstance()
.kRootTable
.getSubTable("/metrics")
.getProtobufTopic(CameraServerJNI.getHostname(), DeviceMetrics.proto)
.publish();
}
var metrics =
new DeviceMetrics(
this.getCpuTemp(),