Merge pull request #659 from michael-loki/metrics_netid

Send netid to metrictank
This commit is contained in:
Jeff 2019-06-19 21:38:41 -04:00 committed by GitHub
commit 4b990ab347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 20 deletions

View File

@ -118,6 +118,14 @@ namespace llarp
if(singleThreaded)
num_nethreads = 0;
}
else if(!strcmp(key, "netid"))
{
metricTags["netid"] = val;
}
else if(!strcmp(key, "nickname"))
{
metricTags["nickname"] = val;
}
}
if(!strcmp(section, "netdb"))
{

View File

@ -124,6 +124,10 @@ namespace llarp
absl::StrAppend(&tagStr, ";", tag.first, "=",
absl::visit(overloaded, tag.second));
}
if(!tags.empty())
{
absl::StrAppend(&tagStr, ";");
}
return tagStr;
}
@ -336,26 +340,6 @@ namespace llarp
#endif
}
if(tags.count("user") == 0)
{
#ifndef _WIN32
const char *username = getlogin();
if(username != nullptr)
{
tags["user"] = username;
}
else
{
tags["user"] = "unknown";
}
#else
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
GetUserName(username, &username_len);
tags["user"] = username;
#endif
}
return tags;
}
} // namespace