Skip to content

Commit

Permalink
detect missing input metrics
Browse files Browse the repository at this point in the history
tilsche committed May 21, 2019
1 parent 521a2ad commit 5d985cd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/combinator.cpp
Original file line number Diff line number Diff line change
@@ -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.";
}

0 comments on commit 5d985cd

Please sign in to comment.