Fix integration test

This commit is contained in:
Alexey Milovidov 2022-08-27 22:27:47 +02:00
parent 91bd6f1d46
commit 6b2e227c8b
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#include <Processors/Formats/Impl/PrometheusTextOutputFormat.h>
#include <optional>
#include <algorithm>
#include <type_traits>
#include <base/defines.h>
@ -306,7 +307,10 @@ void PrometheusTextOutputFormat::write(const Columns & columns, size_t row_num)
}
if (pos.help.has_value() && !columns[*pos.help]->isNullAt(row_num) && current_metric.help.empty())
{
current_metric.help = getString(columns, row_num, *pos.help);
std::replace(current_metric.help.begin(), current_metric.help.end(), '\n', ' ');
}
if (pos.type.has_value() && !columns[*pos.type]->isNullAt(row_num) && current_metric.type.empty())
current_metric.type = getString(columns, row_num, *pos.type);

View File

@ -4,7 +4,9 @@
#include <IO/WriteHelpers.h>
#include <Common/StatusInfo.h>
#include <regex>
#include <regex> /// TODO: this library is harmful.
#include <algorithm>
namespace
{
@ -33,6 +35,11 @@ bool replaceInvalidChars(std::string & metric_name)
return !metric_name.empty();
}
void convertHelpToSingleLine(std::string & help)
{
std::replace(help.begin(), help.end(), '\n', ' ');
}
}
@ -61,6 +68,8 @@ void PrometheusMetricsWriter::write(WriteBuffer & wb) const
std::string metric_name{ProfileEvents::getName(static_cast<ProfileEvents::Event>(i))};
std::string metric_doc{ProfileEvents::getDocumentation(static_cast<ProfileEvents::Event>(i))};
convertHelpToSingleLine(metric_doc);
if (!replaceInvalidChars(metric_name))
continue;
std::string key{profile_events_prefix + metric_name};
@ -80,6 +89,8 @@ void PrometheusMetricsWriter::write(WriteBuffer & wb) const
std::string metric_name{CurrentMetrics::getName(static_cast<CurrentMetrics::Metric>(i))};
std::string metric_doc{CurrentMetrics::getDocumentation(static_cast<CurrentMetrics::Metric>(i))};
convertHelpToSingleLine(metric_doc);
if (!replaceInvalidChars(metric_name))
continue;
std::string key{current_metrics_prefix + metric_name};
@ -115,6 +126,8 @@ void PrometheusMetricsWriter::write(WriteBuffer & wb) const
std::string metric_name{CurrentStatusInfo::getName(static_cast<CurrentStatusInfo::Status>(i))};
std::string metric_doc{CurrentStatusInfo::getDocumentation(static_cast<CurrentStatusInfo::Status>(i))};
convertHelpToSingleLine(metric_doc);
if (!replaceInvalidChars(metric_name))
continue;
std::string key{current_status_prefix + metric_name};