agent_framework::model::Metric get_metric(const ModelType<TYPE>& resource, const ResourceSensorPtr resource_sensor) { const auto metrics = agent_framework::module::get_manager<agent_framework::model::Metric>().get_entries( [&resource, &resource_sensor](const agent_framework::model::Metric& metric) -> bool { return metric.get_component_type() == resource.get_component() && metric.get_component_uuid() == resource.get_uuid() && metric.get_metric_definition_uuid() == resource_sensor->get_definition().get_uuid(); } ); if (metrics.size() != 1) { throw std::runtime_error("Invalid number of Metrics (" + std::to_string(metrics.size()) + ") for " + resource_sensor->get_definition().get_metric_jsonptr() + " reading for " + resource.get_component().to_string() + " with uuid " + resource.get_uuid() ); } return metrics.front(); }