diff --git a/Framework/Core/include/Framework/DeviceMetricsInfo.h b/Framework/Core/include/Framework/DeviceMetricsInfo.h index ad143b7ef9373..05249898c65a2 100644 --- a/Framework/Core/include/Framework/DeviceMetricsInfo.h +++ b/Framework/Core/include/Framework/DeviceMetricsInfo.h @@ -154,11 +154,11 @@ struct DeviceMetricsInfo { std::vector> stringMetrics; // We do not keep so many strings as metrics as history is less relevant. std::vector> floatMetrics; std::vector> enumMetrics; - std::vector()>> intTimestamps; - std::vector()>> uint64Timestamps; - std::vector()>> floatTimestamps; - std::vector()>> stringTimestamps; - std::vector()>> enumTimestamps; + std::vector> intTimestamps; + std::vector> uint64Timestamps; + std::vector> floatTimestamps; + std::vector> stringTimestamps; + std::vector> enumTimestamps; std::vector max; std::vector min; std::vector average; diff --git a/Framework/Core/src/ResourcesMonitoringHelper.cxx b/Framework/Core/src/ResourcesMonitoringHelper.cxx index 1d53d0f1f2a3c..d457edb4844e5 100644 --- a/Framework/Core/src/ResourcesMonitoringHelper.cxx +++ b/Framework/Core/src/ResourcesMonitoringHelper.cxx @@ -8,12 +8,13 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. - #include "ResourcesMonitoringHelper.h" #include "Framework/DeviceMetricsInfo.h" -#define BOOST_BIND_GLOBAL_PLACEHOLDERS -#include -#include +#include +#include + +#include +#include #include #include #include @@ -22,34 +23,28 @@ using namespace o2::framework; template -inline static T retriveValue(T val) +void fillNodeWithValue(rapidjson::Writer& w, + size_t filledMetrics, + MetricsStorage const& metricsStorage, + TimestampsStorage const& timestampsStorage) { - return val; -} - -inline static std::string retriveValue(const std::reference_wrapper val) -{ - return std::string(val.get().data); -} - -template -boost::property_tree::ptree fillNodeWithValue(const DeviceMetricsInfo& deviceMetrics, - const T& metricsStorage, const TIMESTAMPS& timestampsStorage, size_t labelIndex, size_t storeIndex) -{ - unsigned int loopRange = std::min(deviceMetrics.metrics[labelIndex].filledMetrics, metricsStorage[storeIndex].size()); - boost::property_tree::ptree metricNode; + unsigned int loopRange = std::min(filledMetrics, metricsStorage.size()); + w.StartArray(); for (unsigned int idx = 0; idx < loopRange; ++idx) { - boost::property_tree::ptree values; - values.add("timestamp", timestampsStorage[storeIndex][idx]); + w.StartObject(); + w.Key("timestamp"); + std::string s = std::to_string(timestampsStorage[idx]); + w.String(s.c_str(), s.size()); + w.Key("value"); if constexpr (std::is_arithmetic_v) { - values.add("value", std::to_string(retriveValue(std::cref(metricsStorage[storeIndex][idx])))); + w.String(std::to_string(metricsStorage[idx]).c_str()); } else { - values.add("value", retriveValue(std::cref(metricsStorage[storeIndex][idx]))); + w.String(metricsStorage[idx].data); } - metricNode.push_back(std::make_pair("", values)); + w.EndObject(); } - return metricNode; + w.EndArray(); } bool ResourcesMonitoringHelper::dumpMetricsToJSON(const std::vector& metrics, @@ -58,19 +53,23 @@ bool ResourcesMonitoringHelper::dumpMetricsToJSON(const std::vector const& performanceMetricsRegex, std::ostream& out) noexcept { - assert(metrics.size() == specs.size()); if (metrics.empty()) { return false; } - boost::property_tree::ptree root; - for (unsigned int idx = 0; idx < metrics.size(); ++idx) { + rapidjson::OStreamWrapper osw(out); + rapidjson::PrettyWriter w(osw); + + // Top level obejct for all the metrics + w.StartObject(); + for (unsigned int idx = 0; idx < metrics.size(); ++idx) { + w.Key(specs[idx].id.c_str()); const auto& deviceMetrics = metrics[idx]; - boost::property_tree::ptree deviceRoot; + w.StartObject(); for (size_t mi = 0; mi < deviceMetrics.metricLabels.size(); mi++) { std::string_view metricLabel{deviceMetrics.metricLabels[mi].label, deviceMetrics.metricLabels[mi].size}; @@ -83,40 +82,42 @@ bool ResourcesMonitoringHelper::dumpMetricsToJSON(const std::vector bool { @@ -130,39 +131,39 @@ bool ResourcesMonitoringHelper::dumpMetricsToJSON(const std::vector