From 2094b0067b56537edcb96be7737a517416d9ebb3 Mon Sep 17 00:00:00 2001 From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de> Date: Wed, 14 Jun 2023 12:53:35 +0000 Subject: [PATCH] algo: Fix metrics when monitor is not present. --- algo/base/SubChain.h | 1 + algo/global/Reco.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/algo/base/SubChain.h b/algo/base/SubChain.h index b23538e09e..0b0c19744d 100644 --- a/algo/base/SubChain.h +++ b/algo/base/SubChain.h @@ -23,6 +23,7 @@ namespace cbm::algo Monitor& GetMonitor() const { // Need Get-prefix to avoid conflict with Monitor-class name + if (!HasMonitor()) throw std::runtime_error("No monitor available"); return *gsl::make_not_null(fContext)->monitor; } diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index e0ddaee20e..490967f753 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -85,8 +85,10 @@ void Reco::Run(const fles::Timeslice& ts) xpu::timings ts_times = xpu::pop_timer(); - GetMonitor().QueueMetric("cbm_reco", {{"hostname", fles::system::current_hostname()}}, - {{"tsProcessed", 1}, {"bytesProcessed", ts_utils::SizeBytes(ts)}}); + if (HasMonitor()) + GetMonitor().QueueMetric("cbm_reco", {{"hostname", fles::system::current_hostname()}}, + {{"tsProcessed", 1}, {"bytesProcessed", ts_utils::SizeBytes(ts)}}); + PrintTimings(ts_times); } -- GitLab