diff --git a/doc/release-notes-6505.md b/doc/release-notes-6505.md new file mode 100644 index 0000000000000..0c5c69675e836 --- /dev/null +++ b/doc/release-notes-6505.md @@ -0,0 +1,5 @@ +Statistics +----------- + +- The arguments `-statsenabled`, `-statsns`, `-statshostname` have been removed. They were + previously deprecated in v22.0 and will no longer be recognized on runtime. diff --git a/src/init.cpp b/src/init.cpp index 24bef37c05b47..75a7d9f0c9802 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -755,13 +755,10 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-rpcworkqueue=", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::RPC); argsman.AddArg("-server", "Accept command line and JSON-RPC commands", ArgsManager::ALLOW_ANY, OptionsCategory::RPC); - hidden_args.emplace_back("-statsenabled"); argsman.AddArg("-statsbatchsize=", strprintf("Specify the size of each batch of stats messages (default: %d)", DEFAULT_STATSD_BATCH_SIZE), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); argsman.AddArg("-statsduration=", strprintf("Specify the number of milliseconds between stats messages (default: %d)", DEFAULT_STATSD_DURATION), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); argsman.AddArg("-statshost=", strprintf("Specify statsd host (default: %s)", DEFAULT_STATSD_HOST), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); - hidden_args.emplace_back("-statshostname"); argsman.AddArg("-statsport=", strprintf("Specify statsd port (default: %u)", DEFAULT_STATSD_PORT), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); - hidden_args.emplace_back("-statsns"); argsman.AddArg("-statsperiod=", strprintf("Specify the number of seconds between periodic measurements (default: %d)", DEFAULT_STATSD_PERIOD), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); argsman.AddArg("-statsprefix=", strprintf("Specify an optional string prepended to every stats key (default: %s)", DEFAULT_STATSD_PREFIX), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); argsman.AddArg("-statssuffix=", strprintf("Specify an optional string appended to every stats key (default: %s)", DEFAULT_STATSD_SUFFIX), ArgsManager::ALLOW_ANY, OptionsCategory::STATSD); diff --git a/src/stats/client.cpp b/src/stats/client.cpp index 56522d4b66f88..74e14afad56a4 100644 --- a/src/stats/client.cpp +++ b/src/stats/client.cpp @@ -33,72 +33,32 @@ std::unique_ptr g_stats_client; std::unique_ptr InitStatsClient(const ArgsManager& args) { - auto is_enabled = args.GetBoolArg("-statsenabled", /*fDefault=*/false); - auto host = args.GetArg("-statshost", /*fDefault=*/DEFAULT_STATSD_HOST); - - if (is_enabled && host.empty()) { - // Stats are enabled but host has not been specified, then use - // default legacy host. This is to preserve old behavior. - host = "127.0.0.1"; - } else if (!host.empty()) { - // Host is specified but stats are not explcitly enabled. Assume - // that if a host has been specified, we want stats enabled. This - // is new behaviour and will substitute old behaviour in a future - // release. - is_enabled = true; - } - - auto sanitize_string = [](std::string& string) { - // Remove key delimiters from the front and back as they're added back + auto sanitize_string = [](std::string string) { + // Remove key delimiters from the front and back as they're added back in + // the constructor if (!string.empty()) { if (string.front() == STATSD_NS_DELIMITER) string.erase(string.begin()); if (string.back() == STATSD_NS_DELIMITER) string.pop_back(); } + return string; }; - // Get our prefix and suffix and if we get nothing, try again with the - // deprecated argument. If we still get nothing, that's fine, they're optional. - auto prefix = args.GetArg("-statsprefix", DEFAULT_STATSD_PREFIX); - if (prefix.empty()) { - prefix = args.GetArg("-statsns", DEFAULT_STATSD_PREFIX); - } else { - // We restrict sanitization logic to our newly added arguments to - // prevent breaking changes. - sanitize_string(prefix); - // We need to add the delimiter here for backwards compatibility with - // the deprecated argument. - // - // TODO: Move this step into the constructor when removing deprecated - // args support - prefix += STATSD_NS_DELIMITER; - } - - auto suffix = args.GetArg("-statssuffix", DEFAULT_STATSD_SUFFIX); - if (suffix.empty()) { - suffix = args.GetArg("-statshostname", DEFAULT_STATSD_SUFFIX); - } else { - // We restrict sanitization logic to our newly added arguments to - // prevent breaking changes. - sanitize_string(suffix); - } - return std::make_unique( - host, + args.GetArg("-statshost", DEFAULT_STATSD_HOST), args.GetArg("-statsport", DEFAULT_STATSD_PORT), args.GetArg("-statsbatchsize", DEFAULT_STATSD_BATCH_SIZE), args.GetArg("-statsduration", DEFAULT_STATSD_DURATION), - prefix, - suffix, - is_enabled + sanitize_string(args.GetArg("-statsprefix", DEFAULT_STATSD_PREFIX)), + sanitize_string(args.GetArg("-statssuffix", DEFAULT_STATSD_SUFFIX)) ); } StatsdClient::StatsdClient(const std::string& host, uint16_t port, uint64_t batch_size, uint64_t interval_ms, - const std::string& prefix, const std::string& suffix, bool enabled) : - m_prefix{prefix}, + const std::string& prefix, const std::string& suffix) : + m_prefix{[prefix]() { return !prefix.empty() ? prefix + STATSD_NS_DELIMITER : prefix; }()}, m_suffix{[suffix]() { return !suffix.empty() ? STATSD_NS_DELIMITER + suffix : suffix; }()} { - if (!enabled) { + if (host.empty()) { LogPrintf("Transmitting stats are disabled, will not init StatsdClient\n"); return; } diff --git a/src/stats/client.h b/src/stats/client.h index ea3f4f88e996b..e5e8fe7c9a980 100644 --- a/src/stats/client.h +++ b/src/stats/client.h @@ -40,7 +40,7 @@ class StatsdClient { public: explicit StatsdClient(const std::string& host, uint16_t port, uint64_t batch_size, uint64_t interval_ms, - const std::string& prefix, const std::string& suffix, bool enabled); + const std::string& prefix, const std::string& suffix); ~StatsdClient(); public: