Shared/Metric: Initial support for tag value escaping

Fix #18175

(cherry picked from commit 189edc0f23)
This commit is contained in:
jackpoz
2016-10-31 20:34:22 +01:00
committed by joschiwald
parent dc11efd9b4
commit f23c6c4d7e
2 changed files with 9 additions and 1 deletions

View File

@@ -22,7 +22,7 @@
void Metric::Initialize(std::string const& realmName, boost::asio::io_service& ioService, std::function<void()> overallStatusLogger)
{
_realmName = realmName;
_realmName = FormatInfluxDBTagValue(realmName);
_batchTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioService);
_overallStatusTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioService);
_overallStatusLogger = overallStatusLogger;

View File

@@ -79,6 +79,14 @@ private:
static std::string FormatInfluxDBValue(double value) { return std::to_string(value); }
static std::string FormatInfluxDBValue(float value) { return FormatInfluxDBValue(double(value)); }
static std::string FormatInfluxDBTagValue(std::string const& value)
{
// ToDo: should handle '=' and ',' characters too
return boost::replace_all_copy(value, " ", "\\ ");
}
// ToDo: should format TagKey and FieldKey too in the same way as TagValue
public:
static Metric* instance();