Skip to content

Commit

Permalink
Moved unwanted char removal out of metrics framework in favor of the …
Browse files Browse the repository at this point in the history
…caller

being responsible for ensuring the name meets requirements.
  • Loading branch information
kenrowland committed Oct 18, 2023
1 parent efd8e2b commit 185eb1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 7 additions & 2 deletions esp/espcommon/espcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ ESPCOMMON_API std::shared_ptr<hpccMetrics::ScaledHistogramMetric> 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<strlen(removeChars); ++i)
{
metricName.erase(std::remove(metricName.begin(), metricName.end(), removeChars[i]), metricName.end());
}
return registerProfilingMetric(metricName.c_str(), desc, profilingOptions);
}

Expand Down
7 changes: 0 additions & 7 deletions system/jlib/jmetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ bool MetricsManager::addMetric(const std::shared_ptr<IMetric> &pMetric)
bool rc = false;
std::string name = pMetric->queryName();

// Remove unwanted characters from input name
char removeChars[] = "_-* ";
for (unsigned i=0; i<strlen(removeChars); ++i)
{
name.erase(std::remove(name.begin(), name.end(), removeChars[i]), name.end());
}

// Ensure metric name follows naming convention
try
{
Expand Down

0 comments on commit 185eb1d

Please sign in to comment.