From e45035934d3193fd8b34b730eef31e2740caa731 Mon Sep 17 00:00:00 2001 From: jtaub <65861679+jtaub@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:44:38 -0400 Subject: [PATCH] check if dimension value is blank before using it (#594) --- aws/metrics/metrics_manager.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aws/metrics/metrics_manager.cc b/aws/metrics/metrics_manager.cc index 4240c4ea..c9f00670 100644 --- a/aws/metrics/metrics_manager.cc +++ b/aws/metrics/metrics_manager.cc @@ -32,6 +32,12 @@ std::shared_ptr MetricsFinderBuilder::find() { return manager_.get_metric(mf_); } +bool is_blank(const std::string& str) { + return std::all_of(str.begin(), str.end(), [](const unsigned char c) { + return std::isblank(c); + }); +} + Aws::CloudWatch::Model::MetricDatum to_sdk_metric_datum(const std::shared_ptr m, int numBuckets) { auto& a = m->accumulator(); @@ -47,7 +53,7 @@ to_sdk_metric_datum(const std::shared_ptr m, int numBuckets) { for (auto& p : m->all_dimensions()) { if (p.first == "MetricName") { d.SetMetricName(p.second); - } else { + } else if (!is_blank(p.second)) { Aws::CloudWatch::Model::Dimension dim; dim.SetName(p.first); dim.SetValue(p.second);