1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

add some metrics

This commit is contained in:
Jeff Becker 2019-03-26 15:30:10 -04:00
parent 6a544d3f09
commit 0258eb9cb8
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
2 changed files with 18 additions and 1 deletions

View file

@ -25,6 +25,8 @@
#include <link/utp_internal.hpp>
#include <util/metrics.hpp>
namespace llarp
{
namespace utp
@ -85,6 +87,8 @@ namespace llarp
ssize_t s = utp_writev(sock, vecs.data(), vecs.size());
if(s < 0)
return;
METRICS_DYNAMIC_INT_UPDATE(
"utp.session.tx", RouterID(remoteRC.pubkey).ToString().c_str(), s);
m_TXRate += s;
size_t sz = s;
while(vecq.size() && sz >= vecq.front().iov_len)
@ -188,6 +192,8 @@ namespace llarp
Alive();
m_RXRate += sz;
size_t s = sz;
METRICS_DYNAMIC_INT_UPDATE(
"utp.session.rx", RouterID(remoteRC.pubkey).ToString().c_str(), s);
// process leftovers
if(recvBufOffset)
{
@ -351,11 +357,11 @@ namespace llarp
if(arg->error_code == UTP_ETIMEDOUT)
{
link->HandleTimeout(session);
utp_close(arg->socket);
}
else
session->Close();
}
utp_close(arg->socket);
return 0;
}

View file

@ -9,6 +9,7 @@
#include <router_contact.hpp>
#include <util/buffer.hpp>
#include <util/logger.hpp>
#include <util/metrics.hpp>
namespace llarp
{
@ -90,6 +91,14 @@ namespace llarp
default:
return false;
}
{
const std::string host =
handler->from->GetRemoteEndpoint().xtohl().ToString();
char buf[16] = "LinkLayerRecv_";
buf[14] = *strbuf.cur;
buf[15] = 0;
METRICS_DYNAMIC_INCREMENT(buf, host.c_str());
}
handler->msg->session = handler->from;
handler->firstkey = false;
return true;
@ -107,6 +116,8 @@ namespace llarp
bool result = false;
if(msg)
{
const std::string host = from->GetRemoteEndpoint().xtohl().ToString();
METRICS_TIME_BLOCK("HandleMessage", host.c_str());
result = msg->HandleMessage(router);
}
Reset();