From fbf3a8c64b96d942c0fd70fcbf7d9ab064bf45be Mon Sep 17 00:00:00 2001 From: Kevin Burek Date: Tue, 30 Apr 2024 17:34:28 -0400 Subject: [PATCH] stats: Extract route names with forward-slash (#33734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit Message: Extract route names with forward-slash. Additional Description: RDS protocol allows almost any route name, and stats are lightly sanitized before emitting to statsd and prometheus endpoints. This change slightly relaxes the capture group for RDS route names in stats, instead of opening the floodgates to everything, because YAGNI. Risk Level: Low Testing: Updated unit test Docs Changes: None: No restrictions on the route name in RDS were documented before (anything goes, as far as I can tell), so there's nothing to change there. The minimal documentation on route name in RDS stats don't mention allowing, disallowing, or special handling for anything but ":". Release Notes: N/A Platform Specific Features: None Fixes: #32976 Signed-off-by: Kevin Burek --- source/common/config/well_known_names.cc | 6 +++--- test/common/stats/tag_extractor_impl_test.cc | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/common/config/well_known_names.cc b/source/common/config/well_known_names.cc index e5e7d9859f83b..9b5078d8c1bfd 100644 --- a/source/common/config/well_known_names.cc +++ b/source/common/config/well_known_names.cc @@ -23,9 +23,9 @@ std::string expandRegex(const std::string& regex) { {"", R"(TLSv\d\.\d)"}, // A generic name can contain any character except dots. {"", TAG_VALUE_REGEX}, - // Route names may contain dots in addition to alphanumerics and - // dashes with underscores. - {"", R"([\w-\.]+)"}, + // Route names may contain dots and slashes in addition to + // alphanumerics, underscores, and dashes. + {"", R"([\w-\./]+)"}, // Match a prefix that is either a listener plus name or cluster plus name {"", R"((?:listener|cluster)\..*?)"}}); } diff --git a/test/common/stats/tag_extractor_impl_test.cc b/test/common/stats/tag_extractor_impl_test.cc index 81b53ae416d75..e7ed185c9b1be 100644 --- a/test/common/stats/tag_extractor_impl_test.cc +++ b/test/common/stats/tag_extractor_impl_test.cc @@ -393,15 +393,16 @@ TEST(TagExtractorTest, DefaultTagExtractors) { "http.fault.aborts_injected", {fault_connection_manager, fault_downstream_cluster}); + // HTTP Connection Manager and Route Tag rds_hcm; rds_hcm.name_ = tag_names.HTTP_CONN_MANAGER_PREFIX; rds_hcm.value_ = "rds_connection_manager"; Tag rds_route_config; rds_route_config.name_ = tag_names.RDS_ROUTE_CONFIG; - rds_route_config.value_ = "route_config.123"; + rds_route_config.value_ = "agg/route_config.1-23"; - regex_tester.testRegex("http.rds_connection_manager.rds.route_config.123.update_success", + regex_tester.testRegex("http.rds_connection_manager.rds.agg/route_config.1-23.update_success", "http.rds.update_success", {rds_hcm, rds_route_config}); // Listener manager worker id