Skip to content

Commit

Permalink
Add noop backend (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn authored May 4, 2018
1 parent 691878e commit 9462fc5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
51 changes: 51 additions & 0 deletions src/Backends/Noop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
///
/// \file Noop.h
/// \author Adam Wegrzynek <[email protected]>
///

#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 <[email protected]>
class Noop final : public Backend
{
public:
/// Constructs backend
Noop() = default;

/// Default destructor
~Noop() = default;

/// \@param metrics vector of metrics
void send(std::vector<Metric>&& /*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<Metric>&& /*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
6 changes: 6 additions & 0 deletions src/MonitoringFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "Backends/InfoLoggerBackend.h"
#include "Backends/Flume.h"
#include "Backends/Noop.h"

#ifdef _WITH_APPMON
#include "Backends/ApMonBackend.h"
Expand Down Expand Up @@ -55,6 +56,10 @@ std::unique_ptr<Backend> getApMon(http::url /*uri*/) {
}
#endif

std::unique_ptr<Backend> getNoop(http::url /*uri*/) {
return std::make_unique<backends::Noop>();
}

std::unique_ptr<Backend> getFlume(http::url uri) {
return std::make_unique<backends::Flume>(uri.host, uri.port);
}
Expand All @@ -66,6 +71,7 @@ std::unique_ptr<Backend> MonitoringFactory::GetBackend(std::string& url) {
{"influxdb-http", getInfluxDb},
{"apmon", getApMon},
{"flume", getFlume},
{"no-op", getNoop}
};

http::url parsedUrl = http::ParseHttpUrl(url);
Expand Down
20 changes: 20 additions & 0 deletions test/testNoop.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#define BOOST_TEST_MODULE Test Monitoring Flume
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

#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

0 comments on commit 9462fc5

Please sign in to comment.