File tree Expand file tree Collapse file tree 5 files changed +116
-3
lines changed
Expand file tree Collapse file tree 5 files changed +116
-3
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ add_library(Monitoring SHARED
102102 src/Transports/UDP.cxx
103103 src/Transports/TCP.cxx
104104 src/Transports/Unix .cxx
105+ src/Transports/StdOut.cxx
105106 src/Exceptions/MonitoringException.cxx
106107 $<$<BOOL :${ApMon_FOUND} >:src/Backends/ApMonBackend.cxx>
107108 $<$<BOOL :${RdKafka_FOUND} >:src/Backends/Kafka.cxx>
Original file line number Diff line number Diff line change 2626
2727#include " Transports/UDP.h"
2828#include " Transports/Unix.h"
29+ #include " Transports/StdOut.h"
2930
3031#ifdef O2_MONITORING_WITH_APPMON
3132#include " Backends/ApMonBackend.h"
@@ -90,7 +91,10 @@ std::unique_ptr<Backend> getInfluxDb(http::url uri)
9091 auto transport = std::make_unique<transports::Unix>(path);
9192 return std::make_unique<backends::InfluxDB>(std::move (transport));
9293 }
93-
94+ if (uri.protocol == " stdout" ) {
95+ auto transport = std::make_unique<transports::StdOut>();
96+ return std::make_unique<backends::InfluxDB>(std::move (transport));
97+ }
9498 throw std::runtime_error (" InfluxDB transport protocol not supported" );
9599}
96100
@@ -130,6 +134,7 @@ std::unique_ptr<Backend> MonitoringFactory::GetBackend(std::string& url)
130134 {" stdout" , getStdOut},
131135 {" influxdb-udp" , getInfluxDb},
132136 {" influxdb-unix" , getInfluxDb},
137+ {" influxdb-stdout" , getInfluxDb},
133138 {" apmon" , getApMon},
134139 {" no-op" , getNoop},
135140 {" kafka" , getKafka}};
Original file line number Diff line number Diff line change 1+ // Copyright CERN and copyright holders of ALICE O2. This software is
2+ // distributed under the terms of the GNU General Public License v3 (GPL
3+ // Version 3), copied verbatim in the file "COPYING".
4+ //
5+ // See http://alice-o2.web.cern.ch/license for full licensing information.
6+ //
7+ // In applying this license CERN does not waive the privileges and immunities
8+ // granted to it by virtue of its status as an Intergovernmental Organization
9+ // or submit itself to any jurisdiction.
10+
11+ // /
12+ // / \file StdOut.cxx
13+ // / \author Adam Wegrzynek <[email protected] >14+ // /
15+
16+ #include " StdOut.h"
17+ #include < iostream>
18+ #include < string>
19+
20+ namespace o2
21+ {
22+ // / ALICE O2 Monitoring system
23+ namespace monitoring
24+ {
25+ // / Monitoring transports
26+ namespace transports
27+ {
28+
29+ void StdOut::send (std::string&& message)
30+ {
31+ std::cout << message << std::endl;
32+ }
33+
34+ template <typename T>
35+ StdOut& StdOut::operator <<(const T& msg)
36+ {
37+ std::cout << msg;
38+ return *this ;
39+ }
40+
41+ } // namespace transports
42+ } // namespace monitoring
43+ } // namespace o2
Original file line number Diff line number Diff line change 1+ // Copyright CERN and copyright holders of ALICE O2. This software is
2+ // distributed under the terms of the GNU General Public License v3 (GPL
3+ // Version 3), copied verbatim in the file "COPYING".
4+ //
5+ // See http://alice-o2.web.cern.ch/license for full licensing information.
6+ //
7+ // In applying this license CERN does not waive the privileges and immunities
8+ // granted to it by virtue of its status as an Intergovernmental Organization
9+ // or submit itself to any jurisdiction.
10+
11+ // /
12+ // / \file StdOut.h
13+ // / \author Adam Wegrzynek <[email protected] >14+ // /
15+
16+ #ifndef ALICEO2_MONITORING_TRANSPORTS_STDOUT_H
17+ #define ALICEO2_MONITORING_TRANSPORTS_STDOUT_H
18+
19+ #include " TransportInterface.h"
20+
21+ #include < chrono>
22+ #include < string>
23+
24+ namespace o2
25+ {
26+ // / ALICE O2 Monitoring system
27+ namespace monitoring
28+ {
29+ // / Monitoring transports
30+ namespace transports
31+ {
32+
33+ // / \brief Transport that sends string formatted metrics via StdOut
34+ class StdOut : public TransportInterface
35+ {
36+ public:
37+ // / Constructor
38+ StdOut () = default ;
39+
40+ // / Default destructor
41+ ~StdOut () = default ;
42+
43+ // / Sends metric via StdOut
44+ // / \param message r-value string formated
45+ void send (std::string&& message) override ;
46+
47+ // / Overload stream operator
48+ template <typename T>
49+ StdOut& operator <<(const T& msg);
50+ };
51+
52+ } // namespace transports
53+ } // namespace monitoring
54+ } // namespace o2
55+
56+ #endif // ALICEO2_MONITORING_TRANSPORTS_STDOUT_H
Original file line number Diff line number Diff line change 88// granted to it by virtue of its status as an Intergovernmental Organization
99// or submit itself to any jurisdiction.
1010
11- #include " ../src/UriParser/UriParser.h"
12-
1311#define BOOST_TEST_MODULE Test Monitoring InfluxDB
1412#define BOOST_TEST_DYN_LINK
1513#include < boost/test/unit_test.hpp>
14+ #include " ../src/UriParser/UriParser.h"
1615#include " ../src/Transports/UDP.h"
16+ #include " ../src/Transports/StdOut.h"
1717#include " ../src/Backends/InfluxDB.h"
1818
1919namespace o2
@@ -33,6 +33,14 @@ BOOST_AUTO_TEST_CASE(simplySendMetric)
3333 influxBackend.send (metric);
3434}
3535
36+ BOOST_AUTO_TEST_CASE (simplySendMetric2)
37+ {
38+ auto transport = std::make_unique<transports::StdOut>();
39+ o2::monitoring::backends::InfluxDB influxBackend (std::move (transport));
40+ o2::monitoring::Metric metric{10 , " myCrazyMetric" };
41+ influxBackend.send (metric);
42+ }
43+
3644} // namespace Test
3745} // namespace monitoring
3846} // namespace o2
You can’t perform that action at this time.
0 commit comments