From 9462fc579988a0218b1c9c85d76f53ff029c0a12 Mon Sep 17 00:00:00 2001 From: Adam Wegrzynek Date: Fri, 4 May 2018 15:07:35 +0200 Subject: [PATCH] Add noop backend (#53) --- CMakeLists.txt | 1 + src/Backends/Noop.h | 51 +++++++++++++++++++++++++++++++++++++++ src/MonitoringFactory.cxx | 6 +++++ test/testNoop.cxx | 20 +++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 src/Backends/Noop.h create mode 100644 test/testNoop.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fbf07fbd..6b32000de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,6 +145,7 @@ set(TEST_SRCS test/testProcessDetails.cxx test/testProcessMonitor.cxx test/testInfluxDb.cxx + test/testNoop.cxx ) if(APMON_FOUND) list(APPEND TEST_SRCS test/testApMon.cxx) diff --git a/src/Backends/Noop.h b/src/Backends/Noop.h new file mode 100644 index 000000000..3e0cf50ca --- /dev/null +++ b/src/Backends/Noop.h @@ -0,0 +1,51 @@ +/// +/// \file Noop.h +/// \author Adam Wegrzynek +/// + +#ifndef ALICEO2_MONITORING_BACKENDS_NOOP_H +#define ALICEO2_MONITORING_BACKENDS_NOOP_H + +#include "Monitoring/Backend.h" + +namespace o2 +{ +/// ALICE O2 Monitoring system +namespace monitoring +{ +/// Monitoring backends +namespace backends +{ + +/// \brief No-op backend +/// +/// \author Adam Wegrzynek +class Noop final : public Backend +{ + public: + /// Constructs backend + Noop() = default; + + /// Default destructor + ~Noop() = default; + + /// \@param metrics vector of metrics + void send(std::vector&& /*metrics*/) final {} + + /// \param metric reference to metric object: + void send(const Metric& /*metric*/) final {} + + /// \param measurement measurement name + /// \param metrics list of metrics + void sendMultiple(std::string /*measurement*/, std::vector&& /*metrics*/) final {} + + /// \param name tag name + /// \param value tag value that is concatenated to entity string + void addGlobalTag(std::string /*name*/, std::string /*value*/) final {} +}; + +} // namespace backends +} // namespace monitoring +} // namespace o2 + +#endif // ALICEO2_MONITORING_BACKENDS_NOOP_H diff --git a/src/MonitoringFactory.cxx b/src/MonitoringFactory.cxx index 56059c053..02cc1a872 100644 --- a/src/MonitoringFactory.cxx +++ b/src/MonitoringFactory.cxx @@ -12,6 +12,7 @@ #include "Backends/InfoLoggerBackend.h" #include "Backends/Flume.h" +#include "Backends/Noop.h" #ifdef _WITH_APPMON #include "Backends/ApMonBackend.h" @@ -55,6 +56,10 @@ std::unique_ptr getApMon(http::url /*uri*/) { } #endif +std::unique_ptr getNoop(http::url /*uri*/) { + return std::make_unique(); +} + std::unique_ptr getFlume(http::url uri) { return std::make_unique(uri.host, uri.port); } @@ -66,6 +71,7 @@ std::unique_ptr MonitoringFactory::GetBackend(std::string& url) { {"influxdb-http", getInfluxDb}, {"apmon", getApMon}, {"flume", getFlume}, + {"no-op", getNoop} }; http::url parsedUrl = http::ParseHttpUrl(url); diff --git a/test/testNoop.cxx b/test/testNoop.cxx new file mode 100644 index 000000000..f03c0d6b5 --- /dev/null +++ b/test/testNoop.cxx @@ -0,0 +1,20 @@ +#define BOOST_TEST_MODULE Test Monitoring Flume +#define BOOST_TEST_DYN_LINK +#include + +#include "../src/Backends/Noop.h" + +namespace o2 { +namespace monitoring { +namespace Test { + +BOOST_AUTO_TEST_CASE(noopSendMetric) +{ + o2::monitoring::backends::Noop noopBackend{}; + o2::monitoring::Metric metric{10, "myCrazyMetric"}; + noopBackend.send(metric); +} + +} // namespace Test +} // namespace monitoring +} // namespace o2