diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/Common.h | 1 | ||||
-rw-r--r-- | src/common/Metric/Metric.cpp | 2 | ||||
-rw-r--r-- | src/common/Metric/Metric.h | 8 | ||||
-rw-r--r-- | src/common/Utilities/Util.h | 32 |
4 files changed, 27 insertions, 16 deletions
diff --git a/src/common/Common.h b/src/common/Common.h index aa04abacd30..af9b9b17321 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -35,6 +35,7 @@ #include <unordered_map> #include <unordered_set> #include <vector> +#include <numeric> #include <cmath> #include <cstdio> 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(); diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h index fc322a89583..88708a79cd6 100644 --- a/src/common/Utilities/Util.h +++ b/src/common/Utilities/Util.h @@ -327,33 +327,35 @@ TC_COMMON_API bool StringToBool(std::string const& str); // simple class for not-modifyable list template <typename T> -class HookList +class HookList final { - typedef typename std::list<T>::iterator ListIterator; private: - typename std::list<T> m_list; + typedef std::vector<T> ContainerType; + + ContainerType _container; + public: - HookList<T> & operator+=(T t) - { - m_list.push_back(t); - return *this; - } - HookList<T> & operator-=(T t) + typedef typename ContainerType::iterator iterator; + + HookList<T>& operator+=(T t) { - m_list.remove(t); + _container.push_back(t); return *this; } + size_t size() { - return m_list.size(); + return _container.size(); } - ListIterator begin() + + iterator begin() { - return m_list.begin(); + return _container.begin(); } - ListIterator end() + + iterator end() { - return m_list.end(); + return _container.end(); } }; |