1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-05 19:31:04 +00:00

Improve usability of Prometheus metrics backend (#16060)

This commit is contained in:
sfan5 2025-04-23 09:30:04 +02:00 committed by GitHub
parent 00addc3e5d
commit 7c619bdc9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 9 deletions

View file

@ -11,6 +11,7 @@
#include <prometheus/gauge.h>
#include "log.h"
#include "settings.h"
#include "exceptions.h"
#endif
/* Plain implementation */
@ -183,7 +184,16 @@ MetricsBackend *createPrometheusMetricsBackend()
{
std::string addr;
g_settings->getNoEx("prometheus_listener_address", addr);
return new PrometheusMetricsBackend(addr);
if (addr.empty())
return nullptr;
infostream << "Starting Prometheus metrics on " << addr << std::endl;
try {
return new PrometheusMetricsBackend(addr);
} catch (std::exception &e) {
errorstream << "Error while starting Prometheus metrics on " << addr
<< ":\n" << e.what() << std::endl;
throw e;
}
}
#endif