From 5d985cdf431779e52b07a002adb2155a11dcad88 Mon Sep 17 00:00:00 2001 From: tilsche Date: Tue, 21 May 2019 14:47:18 +0200 Subject: [PATCH] detect missing input metrics --- src/combinator.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/combinator.cpp b/src/combinator.cpp index d194f26..3ee2b42 100644 --- a/src/combinator.cpp +++ b/src/combinator.cpp @@ -122,6 +122,7 @@ void Combinator::on_transformer_ready() { // at this point, the metadata of all input metrics is available in this->metadata_ // so we can calculate the rate of the combined metrics + bool missing_inputs = false; for (auto& [combined_name, metric_container] : combined_metrics_) { @@ -135,7 +136,16 @@ void Combinator::on_transformer_ready() for (auto& [input_metric, input_nodes] : metric_container.inputs) { // if rate was not set, this returns NaN, which will propragate through - rate = std::max(rate, metadata_[input_metric].rate()); + try + { + rate = std::max(rate, metadata_.at(input_metric).rate()); + } + catch (const std::out_of_range&) + { + Log::error() << "Missing input " << input_metric << " for combined " + << combined_name; + missing_inputs = true; + } } if (!std::isnan(rate)) @@ -145,6 +155,12 @@ void Combinator::on_transformer_ready() } } + if (missing_inputs) + { + Log::fatal() << "Aborting due to missing input(s)"; + throw std::runtime_error("missing inputs"); + } + Log::info() << "Combinator ready."; }