File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ inline unsigned long StdOut::convertTimestamp(const std::chrono::time_point<std:
4040 .count ();
4141}
4242
43- StdOut::StdOut (const std::string& prefix) : mStream (std::cout ), mPrefix (prefix)
43+ StdOut::StdOut (const std::string& prefix) : mStream (), mPrefix (prefix)
4444{
4545 setVerbosisty (Verbosity::Debug);
4646 MonLogger::Get () << " StdOut backend initialized" << MonLogger::End ();
@@ -83,6 +83,7 @@ void StdOut::send(const Metric& metric)
8383 mStream << ' ,' << tags::TAG_KEY[key] << " =" << tags::GetValue (value);
8484 }
8585 mStream << ' \n ' ;
86+ std::cout << mStream .str ();
8687}
8788
8889} // namespace backends
Original file line number Diff line number Diff line change 1818
1919#include " Monitoring/Backend.h"
2020#include < string>
21+ #include < sstream>
2122
2223namespace o2
2324{
@@ -53,7 +54,7 @@ class StdOut final : public Backend
5354
5455 private:
5556 // / Metric stream
56- std::ostream& mStream ;
57+ std::ostringstream mStream ;
5758
5859 // / Converts timestamp to unsigned long (miliseconds from epoch)
5960 // / \param timestamp timestamp in std::chrono::time_point format
Original file line number Diff line number Diff line change 1+ #include " ../include/Monitoring/MonitoringFactory.h"
2+
3+ #define BOOST_TEST_MODULE Test Monitoring Threads
4+ #define BOOST_TEST_DYN_LINK
5+ #include < boost/test/unit_test.hpp>
6+ #include < thread>
7+ #include < array>
8+
9+ namespace o2
10+ {
11+ namespace monitoring
12+ {
13+ namespace Test
14+ {
15+
16+ using namespace o2 ::monitoring;
17+
18+ BOOST_AUTO_TEST_CASE (retrieveOtherParams)
19+ {
20+ std::array<std::thread, 4 > threads;
21+ for (auto & thread : threads) {
22+ thread = std::thread ([] {
23+ for (int i = 0 ; i < 20 ; i++) {
24+ auto monitoring = MonitoringFactory::Get (" stdout://" );
25+ monitoring->addGlobalTag (" name" , " Readout" );
26+ monitoring->addGlobalTag (tags::Key::Name, tags::Value::Readout);
27+ monitoring->send ({1 , " myCrazyMetricI" });
28+ monitoring->send ({13.33 , " myCrazyMetricS" });
29+ }
30+ });
31+ }
32+
33+ for (auto & thread : threads) {
34+ thread.join ();
35+ }
36+ }
37+
38+ } // namespace Test
39+ } // namespace monitoring
40+ } // namespace o2
You can’t perform that action at this time.
0 commit comments