diff --git a/include/Monitoring/ComplexMetric.h b/include/Monitoring/ComplexMetric.h index efd45b2ba..0f91baa76 100644 --- a/include/Monitoring/ComplexMetric.h +++ b/include/Monitoring/ComplexMetric.h @@ -34,11 +34,6 @@ class ComplexMetric : public o2::monitoring::Metric /// \param name metric name ComplexMetric(int value, const std::string& name); - /// String metric construtor - /// \param value metric value (string) - /// \param name the metric name - ComplexMetric(std::string value, const std::string& name); - /// Double metric constructor /// \param value metric value (double) /// \param name metric name @@ -52,7 +47,7 @@ class ComplexMetric : public o2::monitoring::Metric /// boost variant metric constructor, required by derived metrics logic /// \param value metric value (boost variant) /// \param name metric name - ComplexMetric(std::variant, const std::string& name); + ComplexMetric(std::variant, const std::string& name); /// Default destructor ~ComplexMetric() = default; @@ -61,7 +56,7 @@ class ComplexMetric : public o2::monitoring::Metric void resetTimestamp(); /// Assign operator overload, assignes new values to the metric object - ComplexMetric& operator=(const std::variant& value); + ComplexMetric& operator=(const std::variant& value); }; } // namespace monitoring diff --git a/include/Monitoring/Metric.h b/include/Monitoring/Metric.h index 89a517708..7f46169e8 100644 --- a/include/Monitoring/Metric.h +++ b/include/Monitoring/Metric.h @@ -27,7 +27,6 @@ enum class Verbosity : short { Prod, /// Metric types enum MetricType { INT = 0, - STRING = 1, DOUBLE = 2, UINT64_T = 3 }; @@ -42,11 +41,6 @@ class Metric /// \param name metric name Metric(int value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity); - /// String metric construtor - /// \param value metric value (string) - /// \param name the metric name - Metric(std::string value, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity); - /// Double metric constructor /// \param value metric value (double) /// \param name metric name @@ -60,13 +54,13 @@ class Metric /// boost variant metric constructor, required by derived metrics logic /// \param value metric value (boost variant) /// \param name metric name - Metric(std::variant, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity); + Metric(std::variant, const std::string& name, Verbosity verbosity = Metric::DefaultVerbosity); /// Default destructor ~Metric() = default; /// Assign operator overload, assignes new values to the metric object - Metric& operator=(const std::variant& value); + Metric& operator=(const std::variant& value); /// Name getter /// \return metric name @@ -78,7 +72,7 @@ class Metric /// Value getter /// \return metric value - std::variant getValue() const; + std::variant getValue() const; /// Value type getter /// \return type of value stores inside metric : 0 - int, 1 - std::string, 2 - double @@ -127,7 +121,7 @@ class Metric Metric&& setTags(std::vector>&& tags); /// Metric value - std::variant mValue; + std::variant mValue; /// Metric name std::string mName; diff --git a/src/Backends/ApMonBackend.cxx b/src/Backends/ApMonBackend.cxx index 12a113062..934603fe0 100644 --- a/src/Backends/ApMonBackend.cxx +++ b/src/Backends/ApMonBackend.cxx @@ -83,11 +83,6 @@ void ApMonBackend::send(std::vector&& metrics) doubleValue = value; paramValues[i] = reinterpret_cast(&doubleValue); }, - [&](const std::string& value) { - valueTypes[i] = XDR_STRING; - stringValue = value; - paramValues[i] = const_cast(stringValue.c_str()); - }, [&](uint64_t value) { valueTypes[i] = XDR_REAL64; doubleValue = static_cast(value); @@ -130,10 +125,6 @@ void ApMonBackend::send(const Metric& metric) mApMon->sendTimedParameter(const_cast(entity.c_str()), const_cast(entity.c_str()), const_cast(metric.getName().c_str()), XDR_REAL64, reinterpret_cast(&value), convertTimestamp(metric.getTimestamp())); }, - [this, &metric](const std::string& value) { - mApMon->sendTimedParameter(const_cast(entity.c_str()), const_cast(entity.c_str()), - const_cast(metric.getName().c_str()), XDR_STRING, const_cast(value.c_str()), convertTimestamp(metric.getTimestamp())); - }, [this, &metric](uint64_t value) { mApMon->sendTimedParameter(const_cast(entity.c_str()), const_cast(entity.c_str()), const_cast(metric.getName().c_str()), XDR_REAL64, reinterpret_cast(&value), convertTimestamp(metric.getTimestamp())); diff --git a/src/Backends/InfluxDB.cxx b/src/Backends/InfluxDB.cxx index 2adccdf34..abb2fa7a3 100644 --- a/src/Backends/InfluxDB.cxx +++ b/src/Backends/InfluxDB.cxx @@ -72,7 +72,6 @@ void InfluxDB::sendMultiple(std::string measurement, std::vector&& metri [&convert](uint64_t value) { convert << value << 'i'; }, [&convert](int value) { convert << value << 'i'; }, [&convert](double value) { convert << value; }, - [&convert](const std::string& value) { convert << '"' << value << '"'; }, }, metric.getValue()); convert << ","; diff --git a/src/ComplexMetric.cxx b/src/ComplexMetric.cxx index 448de2e2d..a836da41f 100644 --- a/src/ComplexMetric.cxx +++ b/src/ComplexMetric.cxx @@ -29,10 +29,6 @@ ComplexMetric::ComplexMetric(int value, const std::string& name) : Metric(value, { } -ComplexMetric::ComplexMetric(std::string value, const std::string& name) : Metric(value, name) -{ -} - ComplexMetric::ComplexMetric(double value, const std::string& name) : Metric(value, name) { } @@ -41,7 +37,7 @@ ComplexMetric::ComplexMetric(uint64_t value, const std::string& name) : Metric(v { } -ComplexMetric::ComplexMetric(std::variant value, const std::string& name) : Metric(value, name) +ComplexMetric::ComplexMetric(std::variant value, const std::string& name) : Metric(value, name) { } @@ -50,7 +46,7 @@ void ComplexMetric::resetTimestamp() mTimestamp = Metric::getCurrentTimestamp(); } -ComplexMetric& ComplexMetric::operator=(const std::variant& value) +ComplexMetric& ComplexMetric::operator=(const std::variant& value) { mValue = value; return *this; diff --git a/src/DerivedMetrics.cxx b/src/DerivedMetrics.cxx index f4b61c738..dbe4dcb1e 100644 --- a/src/DerivedMetrics.cxx +++ b/src/DerivedMetrics.cxx @@ -65,9 +65,6 @@ Metric DerivedMetrics::process(Metric& metric, DerivedMetricMode mode) std::for_each(tags.begin(), tags.end(), [&key](auto const& pair) { key += pair.second; }); - if (metric.getType() == MetricType::STRING) { - throw MonitoringException("DerivedMetrics", "Not able to process string values"); - } // search for previous value auto search = mStorage.find(key); diff --git a/src/Metric.cxx b/src/Metric.cxx index 5565652ec..8d16942f6 100644 --- a/src/Metric.cxx +++ b/src/Metric.cxx @@ -35,8 +35,6 @@ int Metric::getType() const { if (std::holds_alternative(mValue)) return 0; - else if (std::holds_alternative(mValue)) - return 1; else if (std::holds_alternative(mValue)) return 2; else @@ -53,11 +51,6 @@ Metric::Metric(int value, const std::string& name, Verbosity verbosity) : mValue overwriteVerbosity(); } -Metric::Metric(std::string value, const std::string& name, Verbosity verbosity) : mValue(value), mName(name), mTimestamp(Metric::getCurrentTimestamp()), mVerbosity(verbosity) -{ - overwriteVerbosity(); -} - Metric::Metric(double value, const std::string& name, Verbosity verbosity) : mValue(value), mName(name), mTimestamp(Metric::getCurrentTimestamp()), mVerbosity(verbosity) { overwriteVerbosity(); @@ -68,12 +61,12 @@ Metric::Metric(uint64_t value, const std::string& name, Verbosity verbosity) : m overwriteVerbosity(); } -Metric::Metric(std::variant value, const std::string& name, Verbosity verbosity) : mValue(value), mName(name), mTimestamp(Metric::getCurrentTimestamp()), mVerbosity(verbosity) +Metric::Metric(std::variant value, const std::string& name, Verbosity verbosity) : mValue(value), mName(name), mTimestamp(Metric::getCurrentTimestamp()), mVerbosity(verbosity) { overwriteVerbosity(); } -std::variant Metric::getValue() const +std::variant Metric::getValue() const { return mValue; } @@ -97,7 +90,7 @@ void Metric::overwriteVerbosity() } } -Metric& Metric::operator=(const std::variant& value) +Metric& Metric::operator=(const std::variant& value) { mValue = value; return *this; diff --git a/src/Monitoring.cxx b/src/Monitoring.cxx index cce8ea082..d04ef403f 100644 --- a/src/Monitoring.cxx +++ b/src/Monitoring.cxx @@ -160,7 +160,7 @@ ComplexMetric& Monitoring::getAutoPushMetric(std::string name, unsigned int inte mMonitorThread = std::thread(&Monitoring::pushLoop, this); mAutoPushInterval = interval; } - mPushStore.emplace_back(std::variant{}, name); + mPushStore.emplace_back(std::variant{}, name); return mPushStore.back(); } diff --git a/src/VariantVisitorAdd.h b/src/VariantVisitorAdd.h index cbe5b76ec..3ed788b60 100644 --- a/src/VariantVisitorAdd.h +++ b/src/VariantVisitorAdd.h @@ -23,7 +23,7 @@ class VariantVisitorAdd template < typename T, typename = typename std::enable_if::value, T>::type> - std::variant operator()(const T& a, const T& b) const + std::variant operator()(const T& a, const T& b) const { return a + b; } @@ -31,7 +31,7 @@ class VariantVisitorAdd /// If arguments have different type an exception is raised /// \throws MonitoringException template - std::variant operator()(const T&, const U&) const + std::variant operator()(const T&, const U&) const { throw MonitoringException("DerivedMetrics/Visitor", "Cannot operate on different or non-numeric types"); } diff --git a/test/testDerived.cxx b/test/testDerived.cxx index fca73a867..288ee72e2 100644 --- a/test/testDerived.cxx +++ b/test/testDerived.cxx @@ -193,13 +193,13 @@ BOOST_AUTO_TEST_CASE(derivedIncrementDouble) BOOST_AUTO_TEST_CASE(testBoostVisitor) { { - std::variant a = 10; - std::variant b = 11; + std::variant a = 10; + std::variant b = 11; auto value = std::visit(VariantVisitorAdd{}, a, b); } { - std::variant a = 10; - std::variant b = 10.10; + std::variant a = 10; + std::variant b = 10.10; BOOST_CHECK_THROW(std::visit(VariantVisitorAdd{}, a, b), o2::monitoring::MonitoringException); BOOST_CHECK_THROW(std::visit(VariantVisitorRate(1000), a, b), o2::monitoring::MonitoringException); } diff --git a/test/testMetric.cxx b/test/testMetric.cxx index a734b95db..4668efcb3 100644 --- a/test/testMetric.cxx +++ b/test/testMetric.cxx @@ -50,16 +50,6 @@ BOOST_AUTO_TEST_CASE(retrieveDouble) BOOST_CHECK_EQUAL(metricInstance.getType(), 2); } -BOOST_AUTO_TEST_CASE(retrieveString) -{ - std::string value = "testString"; - std::string name("metric name"); - Metric metricInstance(value, name); - - BOOST_CHECK_EQUAL(std::get(metricInstance.getValue()), "testString"); - BOOST_CHECK_EQUAL(metricInstance.getType(), 1); -} - BOOST_AUTO_TEST_CASE(retrieveUnsignedLongLong) { uint64_t value = 10000000000000LL; @@ -77,7 +67,7 @@ BOOST_AUTO_TEST_CASE(retrieveWrongType) double value = 1.11; std::string name("metric name"); o2::monitoring::Metric metricInstance(value, name); - BOOST_CHECK_EXCEPTION(std::get(metricInstance.getValue()), std::bad_variant_access, is_critical); + BOOST_CHECK_EXCEPTION(std::get(metricInstance.getValue()), std::bad_variant_access, is_critical); } BOOST_AUTO_TEST_CASE(tags) diff --git a/test/testMonitoring.cxx b/test/testMonitoring.cxx index 01f8bebbf..829c05ba5 100644 --- a/test/testMonitoring.cxx +++ b/test/testMonitoring.cxx @@ -39,7 +39,6 @@ BOOST_AUTO_TEST_CASE(createMonitoring) monitoring->addGlobalTag(tags::Key::Name, tags::Value::Readout); monitoring->send({intMetric, "myCrazyMetricI"}); - monitoring->send({stringMetric, "myCrazyMetricS"}); monitoring->send({doubleMetric, "myCrazyMetricD"}); }