From 5de075390a0379d9b9c559598c761bc42e6251c0 Mon Sep 17 00:00:00 2001 From: pitiwari Date: Tue, 10 Apr 2018 15:52:48 -0700 Subject: [PATCH 1/3] stats: envoy prometheus endpoint fails promlint due to format issue #3019 Signed-off-by: pitiwari --- source/server/http/admin.cc | 2 +- test/server/http/admin_test.cc | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/server/http/admin.cc b/source/server/http/admin.cc index 0049da8be99ee..6cb19190dc222 100644 --- a/source/server/http/admin.cc +++ b/source/server/http/admin.cc @@ -441,7 +441,7 @@ std::string PrometheusStatsFormatter::sanitizeName(const std::string& name) { std::string PrometheusStatsFormatter::formattedTags(const std::vector& tags) { std::vector buf; for (const Stats::Tag& tag : tags) { - buf.push_back(fmt::format("{}=\"{}\"", sanitizeName(tag.name_), tag.value_)); + buf.push_back(fmt::format("{}=\"{}\"", sanitizeName(tag.name_), sanitizeName(tag.value_))); } return StringUtil::join(buf, ","); } diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index a2ee1f35d0fe4..7aacd8e793070 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -377,12 +377,14 @@ TEST(PrometheusStatsFormatter, MetricName) { } TEST(PrometheusStatsFormatter, FormattedTags) { + // if value has - then it should be replaced + // by - std::vector tags; Stats::Tag tag1 = {"a.tag-name", "a.tag-value"}; - Stats::Tag tag2 = {"another_tag_name", "another_tag-value"}; + Stats::Tag tag2 = {"another_tag_name", "another.tag-value"}; tags.push_back(tag1); tags.push_back(tag2); - std::string expected = "a_tag_name=\"a.tag-value\",another_tag_name=\"another_tag-value\""; + std::string expected = "a_tag_name=\"a_tag_value\",another_tag_name=\"another_tag_value\""; auto actual = PrometheusStatsFormatter::formattedTags(tags); EXPECT_EQ(expected, actual); } From f6315950dbe5481a1b4ad4a840fc3912ba2a6744 Mon Sep 17 00:00:00 2001 From: pitiwari Date: Tue, 10 Apr 2018 15:59:17 -0700 Subject: [PATCH 2/3] stats: envoy prometheus endpoint fails promlint due to format issue fixes #3019 Signed-off-by: pitiwari --- test/server/http/admin_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index 7aacd8e793070..6121a47b18b72 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -377,8 +377,7 @@ TEST(PrometheusStatsFormatter, MetricName) { } TEST(PrometheusStatsFormatter, FormattedTags) { - // if value has - then it should be replaced - // by - + // If value has - then it should be replaced by - . std::vector tags; Stats::Tag tag1 = {"a.tag-name", "a.tag-value"}; Stats::Tag tag2 = {"another_tag_name", "another.tag-value"}; From 8099c99f689a1f460fc17ddd659e1dea992fc313 Mon Sep 17 00:00:00 2001 From: pitiwari Date: Tue, 10 Apr 2018 16:34:37 -0700 Subject: [PATCH 3/3] fixed the comment Signed-off-by: pitiwari --- test/server/http/admin_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index 6121a47b18b72..a9ce5d3a3e918 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -377,7 +377,7 @@ TEST(PrometheusStatsFormatter, MetricName) { } TEST(PrometheusStatsFormatter, FormattedTags) { - // If value has - then it should be replaced by - . + // If value has - then it should be replaced by _ . std::vector tags; Stats::Tag tag1 = {"a.tag-name", "a.tag-value"}; Stats::Tag tag2 = {"another_tag_name", "another.tag-value"};