aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2016-10-31 20:34:22 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2016-11-14 20:33:03 +0100
commitf23c6c4d7e4a448400d6fb6dc48a0f5b936620dc (patch)
treeac96363d9c9eb612865d3f961c184e0aa3b09b1d
parentdc11efd9b4232a5fd815c7680b64be579a2b3de4 (diff)
Shared/Metric: Initial support for tag value escaping
Fix #18175 (cherry picked from commit 189edc0f23a2935747eb5eb3555607f4edc15480)
-rw-r--r--src/common/Metric/Metric.cpp2
-rw-r--r--src/common/Metric/Metric.h8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp
index 9484cebcc72..cb6b3b1217b 100644
--- a/src/common/Metric/Metric.cpp
+++ b/src/common/Metric/Metric.cpp
@@ -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;
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index 1855e1d0098..9230983da4d 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -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();