From 185eb1d39dc306bb520b1cb5b8a74fe04c0ee2e2 Mon Sep 17 00:00:00 2001 From: Ken Rowland Date: Wed, 18 Oct 2023 16:18:31 -0400 Subject: [PATCH] Moved unwanted char removal out of metrics framework in favor of the caller being responsible for ensuring the name meets requirements. --- esp/espcommon/espcommon.cpp | 9 +++++++-- system/jlib/jmetrics.cpp | 7 ------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/esp/espcommon/espcommon.cpp b/esp/espcommon/espcommon.cpp index 24bdf7c6788..2599434910b 100644 --- a/esp/espcommon/espcommon.cpp +++ b/esp/espcommon/espcommon.cpp @@ -59,8 +59,13 @@ ESPCOMMON_API std::shared_ptr registerServic { std::string metricName(processName); metricName.append(".").append(serviceName).append(".").append(methodName); - auto no_ = std::remove(metricName.begin(), metricName.end(), '_'); - metricName.erase(no_, metricName.end()); + + // Remove unwanted characters from new metric name + constexpr char removeChars[] = "_-* "; + for (unsigned i=0; i &pMetric) bool rc = false; std::string name = pMetric->queryName(); - // Remove unwanted characters from input name - char removeChars[] = "_-* "; - for (unsigned i=0; i