From cc998abec16bfb1f2d55d92e4c0e6a495576c775 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:02:10 +0000 Subject: [PATCH] fmt: apply `clang-format-diff.py` suggestions --- src/statsd_client.cpp | 28 +++++++++++----------------- src/statsd_client.h | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/statsd_client.cpp b/src/statsd_client.cpp index dd1b37d205..63e178302e 100644 --- a/src/statsd_client.cpp +++ b/src/statsd_client.cpp @@ -61,9 +61,12 @@ bool StatsdClient::ShouldSend(float sample_rate) return sample_rate > std::uniform_real_distribution(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); diff --git a/src/statsd_client.h b/src/statsd_client.h index d253caaeb1..7568d8cd0e 100644 --- a/src/statsd_client.h +++ b/src/statsd_client.h @@ -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 {