Fix runtime issues with metrics

This commit is contained in:
Grant Limberg 2023-04-20 13:02:29 -07:00
parent 1bb3d86e10
commit 688a67136e
No known key found for this signature in database
GPG key ID: 8F2F97D3BE8D7735
3 changed files with 18 additions and 14 deletions

View file

@ -1,5 +1,13 @@
#include <prometheus/simpleapi.h>
namespace prometheus {
namespace simpleapi {
std::shared_ptr<Registry> registry_ptr = std::make_shared<Registry>();
Registry& registry = *registry_ptr;
SaveToFile saver;
}
}
namespace ZeroTier {
namespace Metrics {
// General Controller Metrics

View file

@ -3,6 +3,12 @@
#include <prometheus/simpleapi.h>
namespace prometheus {
namespace simpleapi {
extern std::shared_ptr<Registry> registry_ptr;
}
}
namespace ZeroTier {
namespace Metrics {
// General Controller Metrics

View file

@ -87,17 +87,7 @@
#include "../ext/http-parser/http_parser.h"
#endif
#include <prometheus/simpleapi.h>
namespace prometheus {
namespace simpleapi {
std::shared_ptr<Registry> registry_ptr = std::make_shared<Registry>();
Registry& registry = *registry_ptr;
SaveToFile saver;
}
}
#include "../node/Metrics.hpp"
#if ZT_VAULT_SUPPORT
extern "C" {
@ -858,9 +848,9 @@ public:
_ports[1] = 0;
_ports[2] = 0;
::prometheus::simpleapi::saver.set_registry(::prometheus::simpleapi::registry_ptr);
::prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
::prometheus::simpleapi::saver.set_out_file(_homePath + ZT_PATH_SEPARATOR + "metrics.prom");
prometheus::simpleapi::saver.set_registry(prometheus::simpleapi::registry_ptr);
prometheus::simpleapi::saver.set_delay(std::chrono::seconds(5));
prometheus::simpleapi::saver.set_out_file(_homePath + ZT_PATH_SEPARATOR + "metrics.prom");
#if ZT_VAULT_SUPPORT
curl_global_init(CURL_GLOBAL_DEFAULT);