mirror of https://github.com/oxen-io/lokinet
Integrate metrics into router
This commit is contained in:
parent
f2c5d32399
commit
91f401ff71
|
@ -3,6 +3,9 @@
|
|||
#include <llarp.h>
|
||||
#include <util/fs.hpp>
|
||||
#include <util/logger.hpp>
|
||||
#include <util/metrics_core.hpp>
|
||||
#include <util/metrics_publishers.hpp>
|
||||
#include <util/scheduler.hpp>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
|
@ -248,10 +251,24 @@ main(int argc, char *argv[])
|
|||
#ifndef _WIN32
|
||||
signal(SIGHUP, handle_signal);
|
||||
#endif
|
||||
|
||||
llarp::thread::Scheduler scheduler;
|
||||
llarp::metrics::DefaultManagerGuard metricsGuard;
|
||||
llarp::metrics::PublisherScheduler publisherScheduler(
|
||||
scheduler, metricsGuard.instance());
|
||||
metricsGuard.instance()->addGlobalPublisher(
|
||||
std::make_shared< llarp::metrics::StreamPublisher >(std::cout));
|
||||
|
||||
publisherScheduler.setDefault(absl::Seconds(30));
|
||||
|
||||
scheduler.start();
|
||||
|
||||
code = llarp_main_setup(ctx);
|
||||
if(code == 0)
|
||||
code = llarp_main_run(ctx);
|
||||
llarp_main_free(ctx);
|
||||
|
||||
scheduler.stop();
|
||||
}
|
||||
#ifdef _WIN32
|
||||
::WSACleanup();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <util/buffer.hpp>
|
||||
#include <util/encode.hpp>
|
||||
#include <util/logger.hpp>
|
||||
#include <util/metrics.hpp>
|
||||
#include <util/str.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
@ -1136,12 +1137,14 @@ namespace llarp
|
|||
bool
|
||||
Router::Sign(Signature &sig, const llarp_buffer_t &buf) const
|
||||
{
|
||||
METRICS_TIME_BLOCK("Router", "Sign");
|
||||
return crypto()->sign(sig, identity(), buf);
|
||||
}
|
||||
|
||||
void
|
||||
Router::SendTo(RouterID remote, const ILinkMessage *msg, ILinkLayer *selected)
|
||||
{
|
||||
METRICS_TIME_BLOCK("RouterSendTo", remote.ToString().c_str());
|
||||
llarp_buffer_t buf(linkmsg_buffer);
|
||||
|
||||
if(!msg->BEncode(&buf))
|
||||
|
|
Loading…
Reference in New Issue