Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/server/http/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ std::string PrometheusStatsFormatter::sanitizeName(const std::string& name) {
std::string PrometheusStatsFormatter::formattedTags(const std::vector<Stats::Tag>& tags) {
std::vector<std::string> 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, ",");
}
Expand Down
5 changes: 3 additions & 2 deletions test/server/http/admin_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,13 @@ TEST(PrometheusStatsFormatter, MetricName) {
}

TEST(PrometheusStatsFormatter, FormattedTags) {
// If value has - then it should be replaced by _ .
std::vector<Stats::Tag> 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);
}
Expand Down