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:
parent
00addc3e5d
commit
7c619bdc9a
3 changed files with 20 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue