From 7fcec997ede21253a5e2ffe41abfe1c5880c3ac4 Mon Sep 17 00:00:00 2001 From: Felix Weiglhofer <weiglhofer@fias.uni-frankfurt.de> Date: Thu, 21 Mar 2024 11:28:47 +0000 Subject: [PATCH] monitor: Fix unpacking key names. --- algo/CMakeLists.txt | 1 + algo/base/util/StlUtils.cxx | 21 +++++++++++++++++++++ algo/base/util/StlUtils.h | 7 +++++++ algo/global/Reco.cxx | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 algo/base/util/StlUtils.cxx diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index 32adb41db8..59e4d43164 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -73,6 +73,7 @@ set(SRCS base/Options.cxx base/MainConfig.cxx base/RecoParams.cxx + base/util/StlUtils.cxx base/util/TimingsFormat.cxx data/sts/HitfinderPars.cxx data/sts/LandauTable.cxx diff --git a/algo/base/util/StlUtils.cxx b/algo/base/util/StlUtils.cxx new file mode 100644 index 0000000000..e8db142cc3 --- /dev/null +++ b/algo/base/util/StlUtils.cxx @@ -0,0 +1,21 @@ +/* Copyright (C) 2024 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main + SPDX-License-Identifier: GPL-3.0-only + Authors: Felix Weiglhofer [committer] */ + +#include "StlUtils.h" + +using namespace cbm; + +std::string cbm::Capitalize(std::string_view str) +{ + if (str.empty()) { + return std::string(str); + } + + std::string result(str); + result[0] = std::toupper(result[0]); + for (size_t i = 1; i < result.size(); ++i) + result[i] = std::tolower(result[i]); + + return result; +} diff --git a/algo/base/util/StlUtils.h b/algo/base/util/StlUtils.h index e84898ccdb..61c0846b31 100644 --- a/algo/base/util/StlUtils.h +++ b/algo/base/util/StlUtils.h @@ -11,6 +11,8 @@ */ #include <algorithm> +#include <string> +#include <string_view> namespace cbm { @@ -21,4 +23,9 @@ namespace cbm return std::find(container.begin(), container.end(), value) != container.end(); } + /** + * @brief Capitalize the first letter of a string. The rest of the string is made lowercase. + */ + std::string Capitalize(std::string_view str); + } // namespace cbm diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index d61d7f7553..e793f22184 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -357,7 +357,7 @@ void Reco::QueueUnpackerMetricsDet(const UnpackMonitor<MSMonitor>& monitor) std::string_view det = ToString(monitor.system); - auto MkKey = [&](std::string_view key) { return fmt::format("{}{}", det, key); }; + auto MkKey = [&](std::string_view key) { return fmt::format("{}{}", key, Capitalize(det)); }; GetMonitor().QueueMetric("cbmreco", {{"hostname", fles::system::current_hostname()}, {"child", Opts().ChildId()}}, { -- GitLab