From 84c83403a02e9103de44417af82b542d9945ea12 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:17:20 +0000 Subject: [PATCH 1/4] stats: remove deprecated `-statsenabled` argument --- src/init.cpp | 1 - src/stats/client.cpp | 24 ++++-------------------- src/stats/client.h | 2 +- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 24bef37c05b47..0614e223376ad 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -755,7 +755,6 @@ 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); diff --git a/src/stats/client.cpp b/src/stats/client.cpp index 56522d4b66f88..f93bbbe185d2a 100644 --- a/src/stats/client.cpp +++ b/src/stats/client.cpp @@ -33,21 +33,6 @@ 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 if (!string.empty()) { @@ -83,22 +68,21 @@ std::unique_ptr InitStatsClient(const ArgsManager& args) } 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 + 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) : + const std::string& prefix, const std::string& suffix) : m_prefix{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: From a5a478fff3310bb33ffe1036844cb3d214808f06 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:27:17 +0000 Subject: [PATCH 2/4] stats: remove deprecated `-statsns` argument --- src/init.cpp | 1 - src/stats/client.cpp | 27 ++++++--------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 0614e223376ad..486cb8dea6295 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -760,7 +760,6 @@ void SetupServerArgs(ArgsManager& argsman) 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 f93bbbe185d2a..ecfb1e7170f6b 100644 --- a/src/stats/client.cpp +++ b/src/stats/client.cpp @@ -33,31 +33,16 @@ std::unique_ptr g_stats_client; std::unique_ptr InitStatsClient(const ArgsManager& args) { - 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); @@ -72,14 +57,14 @@ std::unique_ptr InitStatsClient(const ArgsManager& args) args.GetArg("-statsport", DEFAULT_STATSD_PORT), args.GetArg("-statsbatchsize", DEFAULT_STATSD_BATCH_SIZE), args.GetArg("-statsduration", DEFAULT_STATSD_DURATION), - prefix, + sanitize_string(args.GetArg("-statsprefix", DEFAULT_STATSD_PREFIX)), 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) : - m_prefix{prefix}, + m_prefix{[prefix]() { return !prefix.empty() ? prefix + STATSD_NS_DELIMITER : prefix; }()}, m_suffix{[suffix]() { return !suffix.empty() ? STATSD_NS_DELIMITER + suffix : suffix; }()} { if (host.empty()) { From 8a7a96c51f4dbf3d8534d6ccd0d1355cf9ec54c4 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:28:56 +0000 Subject: [PATCH 3/4] stats: remove deprecated `-statshostname` argument --- src/init.cpp | 1 - src/stats/client.cpp | 11 +---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 486cb8dea6295..75a7d9f0c9802 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -758,7 +758,6 @@ void SetupServerArgs(ArgsManager& argsman) 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); 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); diff --git a/src/stats/client.cpp b/src/stats/client.cpp index ecfb1e7170f6b..74e14afad56a4 100644 --- a/src/stats/client.cpp +++ b/src/stats/client.cpp @@ -43,22 +43,13 @@ std::unique_ptr InitStatsClient(const ArgsManager& args) return string; }; - 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( 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), sanitize_string(args.GetArg("-statsprefix", DEFAULT_STATSD_PREFIX)), - suffix + sanitize_string(args.GetArg("-statssuffix", DEFAULT_STATSD_SUFFIX)) ); } From 91e26442ea3762ea2f9a40919b1710c5b46767da Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Mon, 23 Dec 2024 07:05:05 +0000 Subject: [PATCH 4/4] stats: add release notes for removal of deprecated arguments --- doc/release-notes-6505.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 doc/release-notes-6505.md 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.