Skip to content

Commit

Permalink
check if dimension value is blank before using it (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtaub authored Oct 8, 2024
1 parent 0eafc8d commit e450359
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion aws/metrics/metrics_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ std::shared_ptr<Metric> 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<Metric> m, int numBuckets) {
auto& a = m->accumulator();
Expand All @@ -47,7 +53,7 @@ to_sdk_metric_datum(const std::shared_ptr<Metric> 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);
Expand Down

0 comments on commit e450359

Please sign in to comment.