mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fmt: apply clang-format-diff.py
suggestions
This commit is contained in:
parent
0401c581eb
commit
cc998abec1
@ -61,9 +61,12 @@ bool StatsdClient::ShouldSend(float sample_rate)
|
||||
return sample_rate > std::uniform_real_distribution<float>(0.f, 1.f)(insecure_rand);
|
||||
}
|
||||
|
||||
StatsdClient::StatsdClient(const std::string& host, const std::string& nodename, uint16_t port,
|
||||
const std::string& ns, bool enabled)
|
||||
: m_port{port}, m_host{host}, m_nodename{nodename}, m_ns{ns}
|
||||
StatsdClient::StatsdClient(const std::string& host, const std::string& nodename, uint16_t port, const std::string& ns,
|
||||
bool enabled) :
|
||||
m_port{port},
|
||||
m_host{host},
|
||||
m_nodename{nodename},
|
||||
m_ns{ns}
|
||||
{
|
||||
if (!enabled) {
|
||||
LogPrintf("Transmitting stats are disabled, will not init StatsdClient\n");
|
||||
@ -99,22 +102,15 @@ StatsdClient::StatsdClient(const std::string& host, const std::string& nodename,
|
||||
void StatsdClient::cleanup(std::string& key)
|
||||
{
|
||||
auto pos = key.find_first_of(":|@");
|
||||
while (pos != std::string::npos)
|
||||
{
|
||||
while (pos != std::string::npos) {
|
||||
key[pos] = '_';
|
||||
pos = key.find_first_of(":|@");
|
||||
}
|
||||
}
|
||||
|
||||
bool StatsdClient::dec(const std::string& key, float sample_rate)
|
||||
{
|
||||
return count(key, -1, sample_rate);
|
||||
}
|
||||
bool StatsdClient::dec(const std::string& key, float sample_rate) { return count(key, -1, sample_rate); }
|
||||
|
||||
bool StatsdClient::inc(const std::string& key, float sample_rate)
|
||||
{
|
||||
return count(key, 1, sample_rate);
|
||||
}
|
||||
bool StatsdClient::inc(const std::string& key, float sample_rate) { return count(key, 1, sample_rate); }
|
||||
|
||||
bool StatsdClient::count(const std::string& key, int64_t value, float sample_rate)
|
||||
{
|
||||
@ -148,8 +144,7 @@ bool StatsdClient::send(std::string key, int64_t value, const std::string& type,
|
||||
}
|
||||
|
||||
// partition stats by node name if set
|
||||
if (!m_nodename.empty())
|
||||
key = key + "." + m_nodename;
|
||||
if (!m_nodename.empty()) key = key + "." + m_nodename;
|
||||
|
||||
cleanup(key);
|
||||
|
||||
@ -173,8 +168,7 @@ bool StatsdClient::sendDouble(std::string key, double value, const std::string&
|
||||
}
|
||||
|
||||
// partition stats by node name if set
|
||||
if (!m_nodename.empty())
|
||||
key = key + "." + m_nodename;
|
||||
if (!m_nodename.empty()) key = key + "." + m_nodename;
|
||||
|
||||
cleanup(key);
|
||||
|
||||
|
@ -22,7 +22,7 @@ static const std::string DEFAULT_STATSD_NAMESPACE{""};
|
||||
// schedule periodic measurements, in seconds: default - 1 minute, min - 5 sec, max - 1h.
|
||||
static constexpr int DEFAULT_STATSD_PERIOD{60};
|
||||
static constexpr int MIN_STATSD_PERIOD{5};
|
||||
static constexpr int MAX_STATSD_PERIOD{60*60};
|
||||
static constexpr int MAX_STATSD_PERIOD{60 * 60};
|
||||
|
||||
namespace statsd {
|
||||
class StatsdClient {
|
||||
|
Loading…
Reference in New Issue
Block a user