From 9caf96030ee9de14131e898758a37bea31f570a4 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 8 Apr 2026 16:46:29 -0700 Subject: [PATCH 1/2] disable built-in SDK stats events by default to reduce OneCollector load --- lib/config/RuntimeConfig_Default.hpp | 3 +++ lib/stats/Statistics.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/config/RuntimeConfig_Default.hpp b/lib/config/RuntimeConfig_Default.hpp index 27a8f6758..d911ff9fd 100644 --- a/lib/config/RuntimeConfig_Default.hpp +++ b/lib/config/RuntimeConfig_Default.hpp @@ -33,6 +33,9 @@ namespace MAT_NS_BEGIN {/* Parameter that allows to split stats events by tenant */ {"split", false}, {"interval", 1800}, + /* Stats are disabled by default for the built-in shared token + to reduce OneCollector load (see #1420). Set to true to opt in. */ + {"enabled", false}, {"tokenProd", STATS_TOKEN_PROD}, {"tokenInt", STATS_TOKEN_INT}}}, {"utc", diff --git a/lib/stats/Statistics.cpp b/lib/stats/Statistics.cpp index 2f421714c..4abf09563 100644 --- a/lib/stats/Statistics.cpp +++ b/lib/stats/Statistics.cpp @@ -7,6 +7,7 @@ #include "Statistics.hpp" #include "ILogManager.hpp" +#include "mat/config.h" #include "utils/Utils.hpp" #include @@ -60,12 +61,21 @@ namespace MAT_NS_BEGIN { return; } + std::string tenantToken = m_config.GetMetaStatsTenantToken(); + // Stats are disabled by default for the built-in shared token to + // reduce OneCollector load (see #1420). Custom tokens always send. + // Set config["metaStats"]["enabled"] = true to opt in. + bool isDefaultToken = (tenantToken == STATS_TOKEN_PROD || tenantToken == STATS_TOKEN_INT); + if (isDefaultToken && !static_cast(m_config[CFG_MAP_METASTATS_CONFIG]["enabled"])) + { + return; + } + std::vector< ::CsProtocol::Record> records; { LOCKGUARD(m_metaStats_mtx); records = m_metaStats.generateStatsEvent(rollupKind); } - std::string tenantToken = m_config.GetMetaStatsTenantToken(); for (auto& record : records) { From 3d4b5eeec1e595b2e47294c7240f325cc74a5a2f Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Wed, 8 Apr 2026 17:34:28 -0700 Subject: [PATCH 2/2] Fix BasicFuncTests --- tests/functests/BasicFuncTests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/functests/BasicFuncTests.cpp b/tests/functests/BasicFuncTests.cpp index 51848d054..e1138ebf1 100644 --- a/tests/functests/BasicFuncTests.cpp +++ b/tests/functests/BasicFuncTests.cpp @@ -200,6 +200,7 @@ class BasicFuncTests : public ::testing::Test, configuration[CFG_STR_COLLECTOR_URL] = serverAddress.c_str(); configuration[CFG_MAP_HTTP][CFG_BOOL_HTTP_COMPRESSION] = false; // disable compression for now configuration[CFG_MAP_METASTATS_CONFIG][CFG_INT_METASTATS_INTERVAL] = 30 * 60; // 30 mins + configuration[CFG_MAP_METASTATS_CONFIG]["enabled"] = true; // opt in to stats (disabled by default since #1420) configuration["name"] = __FILE__; configuration["version"] = "1.0.0"; @@ -1140,6 +1141,7 @@ TEST_F(BasicFuncTests, killSwitchWorks) configuration[CFG_STR_COLLECTOR_URL] = serverAddress.c_str(); configuration[CFG_MAP_HTTP][CFG_BOOL_HTTP_COMPRESSION] = false; // disable compression for now configuration[CFG_MAP_METASTATS_CONFIG]["interval"] = 30 * 60; // 30 mins + configuration[CFG_MAP_METASTATS_CONFIG]["enabled"] = true; // opt in to stats (disabled by default since #1420) configuration["name"] = __FILE__; configuration["version"] = "1.0.0"; @@ -1222,6 +1224,7 @@ TEST_F(BasicFuncTests, killIsTemporary) configuration[CFG_STR_COLLECTOR_URL] = serverAddress.c_str(); configuration[CFG_MAP_HTTP][CFG_BOOL_HTTP_COMPRESSION] = false; // disable compression for now configuration[CFG_MAP_METASTATS_CONFIG]["interval"] = 30 * 60; // 30 mins + configuration[CFG_MAP_METASTATS_CONFIG]["enabled"] = true; // opt in to stats (disabled by default since #1420) configuration["name"] = __FILE__; configuration["version"] = "1.0.0";