mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
stats: const
-ify variables and arguments
We cannot convert `DEFAULT_STATSD*` to `std::string_view`s as they're being used as default arguments and `GetArgs` expects `std::string`s
This commit is contained in:
parent
9f96723774
commit
0401c581eb
@ -61,8 +61,8 @@ bool StatsdClient::ShouldSend(float sample_rate)
|
|||||||
return sample_rate > std::uniform_real_distribution<float>(0.f, 1.f)(insecure_rand);
|
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,
|
StatsdClient::StatsdClient(const std::string& host, const std::string& nodename, uint16_t port,
|
||||||
bool enabled)
|
const std::string& ns, bool enabled)
|
||||||
: m_port{port}, m_host{host}, m_nodename{nodename}, m_ns{ns}
|
: m_port{port}, m_host{host}, m_nodename{nodename}, m_ns{ns}
|
||||||
{
|
{
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
|
@ -13,22 +13,22 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
static const bool DEFAULT_STATSD_ENABLE = false;
|
static constexpr bool DEFAULT_STATSD_ENABLE{false};
|
||||||
static const uint16_t DEFAULT_STATSD_PORT = 8125;
|
static constexpr uint16_t DEFAULT_STATSD_PORT{8125};
|
||||||
static const std::string DEFAULT_STATSD_HOST = "127.0.0.1";
|
static const std::string DEFAULT_STATSD_HOST{"127.0.0.1"};
|
||||||
static const std::string DEFAULT_STATSD_HOSTNAME = "";
|
static const std::string DEFAULT_STATSD_HOSTNAME{""};
|
||||||
static const std::string DEFAULT_STATSD_NAMESPACE = "";
|
static const std::string DEFAULT_STATSD_NAMESPACE{""};
|
||||||
|
|
||||||
// schedule periodic measurements, in seconds: default - 1 minute, min - 5 sec, max - 1h.
|
// schedule periodic measurements, in seconds: default - 1 minute, min - 5 sec, max - 1h.
|
||||||
static const int DEFAULT_STATSD_PERIOD = 60;
|
static constexpr int DEFAULT_STATSD_PERIOD{60};
|
||||||
static const int MIN_STATSD_PERIOD = 5;
|
static constexpr int MIN_STATSD_PERIOD{5};
|
||||||
static const int MAX_STATSD_PERIOD = 60 * 60;
|
static constexpr int MAX_STATSD_PERIOD{60*60};
|
||||||
|
|
||||||
namespace statsd {
|
namespace statsd {
|
||||||
class StatsdClient {
|
class StatsdClient {
|
||||||
public:
|
public:
|
||||||
explicit StatsdClient(const std::string& host, const std::string& nodename, uint16_t port, const std::string& ns,
|
explicit StatsdClient(const std::string& host, const std::string& nodename, uint16_t port,
|
||||||
bool enabled);
|
const std::string& ns, bool enabled);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool inc(const std::string& key, float sample_rate = 1.f);
|
bool inc(const std::string& key, float sample_rate = 1.f);
|
||||||
|
Loading…
Reference in New Issue
Block a user