artdaq_utilities  v1_07_01
MetricManager_t.cc
1 
2 #define TRACE_NAME "MetricManager_t"
3 #include "trace.h"
4 
5 #include "artdaq-utilities/Plugins/MakeParameterSet.hh"
6 #include "artdaq-utilities/Plugins/MetricManager.hh"
8 
9 #define BOOST_TEST_MODULE MetricManager_t
10 #include "cetlib/quiet_unit_test.hpp"
11 #include "cetlib_except/exception.h"
12 
13 BOOST_AUTO_TEST_SUITE(MetricManager_test)
14 
15 #define TRACE_REQUIRE_EQUAL(l, r) \
16  do \
17  { \
18  if ((l) == (r)) \
19  { \
20  TLOG(TLVL_DEBUG) << __LINE__ << ": Checking if " << #l << " (" << (l) << ") equals " << #r << " (" << (r) << ")...YES!"; \
21  } \
22  else \
23  { \
24  TLOG(TLVL_ERROR) << __LINE__ << ": Checking if " << #l << " (" << (l) << ") equals " << #r << " (" << (r) << ")...NO!"; \
25  } \
26  BOOST_REQUIRE_EQUAL((l), (r)); \
27  } while (0)
28 
29 using seconds = std::chrono::duration<double, std::ratio<1>>;
30 
31 constexpr double GetElapsedTime(std::chrono::steady_clock::time_point then,
32  std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now())
33 {
34  return std::chrono::duration_cast<seconds>(now - then).count();
35 }
36 
37 BOOST_AUTO_TEST_CASE(Construct)
38 {
39  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Construct" << TLOG_ENDL;
41  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
42  TRACE_REQUIRE_EQUAL(mm.Running(), false);
43  TRACE_REQUIRE_EQUAL(mm.Active(), false);
44  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
45  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
46  TLOG_DEBUG("MetricManager_t") << "END TEST Construct" << TLOG_ENDL;
47 }
48 
49 BOOST_AUTO_TEST_CASE(Initialize)
50 {
51  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Initialize" << TLOG_ENDL;
53  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
54  TRACE_REQUIRE_EQUAL(mm.Running(), false);
55  TRACE_REQUIRE_EQUAL(mm.Active(), false);
56  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
57  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
58 
59  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 1.0}";
60  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
61 
62  mm.initialize(pset, "MetricManager_t");
63  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
64  TRACE_REQUIRE_EQUAL(mm.Running(), false);
65  TRACE_REQUIRE_EQUAL(mm.Active(), false);
66 
67  mm.do_start();
68  TRACE_REQUIRE_EQUAL(mm.Running(), true);
69  TRACE_REQUIRE_EQUAL(mm.Active(), true);
70  TLOG_DEBUG("MetricManager_t") << "END TEST Initialize" << TLOG_ENDL;
71 }
72 
73 BOOST_AUTO_TEST_CASE(Initialize_WithError)
74 {
75  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Initialize_WithError" << TLOG_ENDL;
77  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
78  TRACE_REQUIRE_EQUAL(mm.Running(), false);
79  TRACE_REQUIRE_EQUAL(mm.Active(), false);
80  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
81  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
82 
83  std::string testConfig = "err: { level: 5 metricPluginType: nonExistentPluginType reporting_interval: 1.0}";
84  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
85 
86  mm.initialize(pset, "MetricManager_t");
87  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
88  TRACE_REQUIRE_EQUAL(mm.Running(), false);
89 
90  mm.do_start();
91  TRACE_REQUIRE_EQUAL(mm.Running(), true);
92  TRACE_REQUIRE_EQUAL(mm.Active(), false);
93  TLOG_DEBUG("MetricManager_t") << "END TEST Initialize_WithError" << TLOG_ENDL;
94 }
95 
96 BOOST_AUTO_TEST_CASE(Shutdown)
97 {
98  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Shutdown" << TLOG_ENDL;
100  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
101  TRACE_REQUIRE_EQUAL(mm.Running(), false);
102  TRACE_REQUIRE_EQUAL(mm.Active(), false);
103  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
104  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
105 
106  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 1.0}";
107  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
108 
109  mm.initialize(pset, "MetricManager_t");
110  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
111  TRACE_REQUIRE_EQUAL(mm.Running(), false);
112  TRACE_REQUIRE_EQUAL(mm.Active(), false);
113 
114  mm.do_start();
115  TRACE_REQUIRE_EQUAL(mm.Running(), true);
116  TRACE_REQUIRE_EQUAL(mm.Active(), true);
117 
118  mm.do_stop();
119  TRACE_REQUIRE_EQUAL(mm.Running(), false);
120  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
121 
122  mm.shutdown();
123  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
124  TLOG_DEBUG("MetricManager_t") << "END TEST Shutdown" << TLOG_ENDL;
125 }
126 
127 BOOST_AUTO_TEST_CASE(SendMetric_String)
128 {
129  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetric_String" << TLOG_ENDL;
131  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
132  TRACE_REQUIRE_EQUAL(mm.Running(), false);
133  TRACE_REQUIRE_EQUAL(mm.Active(), false);
134  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
135  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
136 
137  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 1.0}";
138  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
139 
140  mm.initialize(pset, "MetricManager_t");
141  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
142  TRACE_REQUIRE_EQUAL(mm.Running(), false);
143  TRACE_REQUIRE_EQUAL(mm.Active(), false);
144 
145  mm.do_start();
146  TRACE_REQUIRE_EQUAL(mm.Running(), true);
147  TRACE_REQUIRE_EQUAL(mm.Active(), true);
148 
149  mm.sendMetric("Test Metric", "This is a test", "Units", 2, artdaq::MetricMode::LastPoint);
150 
151  mm.do_stop();
152  TRACE_REQUIRE_EQUAL(mm.Running(), false);
153  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
154 
155  mm.shutdown();
156  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
157  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetric_String" << TLOG_ENDL;
158 }
159 
160 BOOST_AUTO_TEST_CASE(SendMetrics) // NOLINT(readability-function-size)
161 {
162  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetrics" << TLOG_ENDL;
164  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
165  TRACE_REQUIRE_EQUAL(mm.Running(), false);
166  TRACE_REQUIRE_EQUAL(mm.Active(), false);
167  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
168  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
169 
170  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 0.5 send_zeros: false} metric_send_maximum_delay_ms: 100 metric_holdoff_us: 10000";
171  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
172 
173  mm.initialize(pset, "MetricManager_t");
174  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
175  TRACE_REQUIRE_EQUAL(mm.Running(), false);
176  TRACE_REQUIRE_EQUAL(mm.Active(), false);
177 
178  mm.do_start();
179  TRACE_REQUIRE_EQUAL(mm.Running(), true);
180  TRACE_REQUIRE_EQUAL(mm.Active(), true);
181 
182  mm.sendMetric("Test Metric LastPoint", 1, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
183  mm.sendMetric("Test Metric LastPoint", 5, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
184  while (mm.metricManagerBusy())
185  {
186  usleep(1000);
187  }
188 
189  {
191  bool present = false;
192  for (auto& point : artdaq::TestMetric::received_metrics)
193  {
194  TLOG(TLVL_DEBUG) << "Metric: " << point.metric << ", Value: " << point.value << ", Units: " << point.unit;
195  if (point.metric == "Test Metric LastPoint")
196  {
197  TRACE_REQUIRE_EQUAL(point.value, "5");
198  TRACE_REQUIRE_EQUAL(point.unit, "Units");
199  present = true;
200  }
201  }
202  BOOST_REQUIRE(present);
203  artdaq::TestMetric::received_metrics.clear();
205  }
206 
207  mm.sendMetric("Test Metric Accumulate", 4, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
208  mm.sendMetric("Test Metric Accumulate", 5, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
209  while (mm.metricManagerBusy())
210  {
211  usleep(1000);
212  }
213 
214  {
216  bool present = false;
217  for (auto& point : artdaq::TestMetric::received_metrics)
218  {
219  if (point.metric == "Test Metric Accumulate")
220  {
221  TRACE_REQUIRE_EQUAL(point.value, "9");
222  TRACE_REQUIRE_EQUAL(point.unit, "Units");
223  present = true;
224  }
225  }
226  BOOST_REQUIRE(present);
227  artdaq::TestMetric::received_metrics.clear();
229  }
230 
231  mm.sendMetric("Test Metric Average", 1, "Units", 2, artdaq::MetricMode::Average, "", true);
232  mm.sendMetric("Test Metric Average", 3, "Units", 2, artdaq::MetricMode::Average, "", true);
233  while (mm.metricManagerBusy())
234  {
235  usleep(1000);
236  }
237 
238  {
240  bool present = false;
241  for (auto& point : artdaq::TestMetric::received_metrics)
242  {
243  if (point.metric == "Test Metric Average")
244  {
245  TRACE_REQUIRE_EQUAL(std::stof(point.value), 2);
246  TRACE_REQUIRE_EQUAL(point.unit, "Units");
247  present = true;
248  }
249  }
250  BOOST_REQUIRE(present);
251  artdaq::TestMetric::received_metrics.clear();
253  }
254 
255  mm.sendMetric("Test Metric Rate", 4, "Units", 2, artdaq::MetricMode::Rate, "", true);
256  mm.sendMetric("Test Metric Rate", 5, "Units", 2, artdaq::MetricMode::Rate, "", true);
257  while (mm.metricManagerBusy())
258  {
259  usleep(1000);
260  }
261 
262  {
264  bool present = false;
265  for (auto& point : artdaq::TestMetric::received_metrics)
266  {
267  if (point.metric == "Test Metric Rate")
268  {
269  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
270  present = true;
271  }
272  }
273  BOOST_REQUIRE(present);
274  artdaq::TestMetric::received_metrics.clear();
276  }
277 
278  mm.sendMetric("Test Metric AccumulateAndRate", 4, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
279  mm.sendMetric("Test Metric AccumulateAndRate", 5, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
280  while (mm.metricManagerBusy())
281  {
282  usleep(1000);
283  }
284 
285  {
287  int present = 0;
288  for (auto& point : artdaq::TestMetric::received_metrics)
289  {
290  if (point.metric == "Test Metric AccumulateAndRate - Total")
291  {
292  TRACE_REQUIRE_EQUAL(point.value, "9");
293  TRACE_REQUIRE_EQUAL(point.unit, "Units");
294  present++;
295  }
296  if (point.metric == "Test Metric AccumulateAndRate - Rate")
297  {
298  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
299  present++;
300  }
301  }
302  TRACE_REQUIRE_EQUAL(present, 2);
303  artdaq::TestMetric::received_metrics.clear();
305  }
306 
307  mm.do_stop();
308  TRACE_REQUIRE_EQUAL(mm.Running(), false);
309  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
310 
311  mm.shutdown();
312  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
313  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics" << TLOG_ENDL;
314 }
315 
316 BOOST_AUTO_TEST_CASE(SendMetrics_Levels) // NOLINT(readability-function-size)
317 {
318  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetrics_Levels" << TLOG_ENDL;
320  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
321  TRACE_REQUIRE_EQUAL(mm.Running(), false);
322  TRACE_REQUIRE_EQUAL(mm.Active(), false);
323  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
324  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
325 
326  std::string testConfig = "msgFac: { level: 0 metric_levels: [ 1, 2 ] level_string: \"3-5,9,7\" metricPluginType: test reporting_interval: 0.1 send_zeros: false} metric_send_maximum_delay_ms: 100";
327  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
328 
329  mm.initialize(pset, "MetricManager_t");
330  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
331  TRACE_REQUIRE_EQUAL(mm.Running(), false);
332  TRACE_REQUIRE_EQUAL(mm.Active(), false);
333 
334  mm.do_start();
335  TRACE_REQUIRE_EQUAL(mm.Running(), true);
336  TRACE_REQUIRE_EQUAL(mm.Active(), true);
337 
338  mm.sendMetric("Test Metric 0", 0, "Units", 0, artdaq::MetricMode::LastPoint, "", true);
339  mm.sendMetric("Test Metric 1", 1, "Units", 1, artdaq::MetricMode::LastPoint, "", true);
340  mm.sendMetric("Test Metric 2", 2, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
341  mm.sendMetric("Test Metric 3", 3, "Units", 3, artdaq::MetricMode::LastPoint, "", true);
342  mm.sendMetric("Test Metric 4", 4, "Units", 4, artdaq::MetricMode::LastPoint, "", true);
343  mm.sendMetric("Test Metric 5", 5, "Units", 5, artdaq::MetricMode::LastPoint, "", true);
344  mm.sendMetric("Test Metric 6", 6, "Units", 6, artdaq::MetricMode::LastPoint, "", true);
345  mm.sendMetric("Test Metric 7", 7, "Units", 7, artdaq::MetricMode::LastPoint, "", true);
346  mm.sendMetric("Test Metric 8", 8, "Units", 8, artdaq::MetricMode::LastPoint, "", true);
347  mm.sendMetric("Test Metric 9", 9, "Units", 9, artdaq::MetricMode::LastPoint, "", true);
348  mm.sendMetric("Test Metric 10", 10, "Units", 10, artdaq::MetricMode::LastPoint, "", true);
349  std::bitset<11> received_metrics_;
350 
351  while (mm.metricManagerBusy())
352  {
353  usleep(1000);
354  }
355 
356  {
358  for (auto& point : artdaq::TestMetric::received_metrics)
359  {
360  if (point.metric == "Test Metric 0")
361  {
362  TRACE_REQUIRE_EQUAL(point.value, "0");
363  TRACE_REQUIRE_EQUAL(point.unit, "Units");
364  received_metrics_[0] = true;
365  }
366  if (point.metric == "Test Metric 1")
367  {
368  TRACE_REQUIRE_EQUAL(point.value, "1");
369  TRACE_REQUIRE_EQUAL(point.unit, "Units");
370  received_metrics_[1] = true;
371  }
372  if (point.metric == "Test Metric 2")
373  {
374  TRACE_REQUIRE_EQUAL(point.value, "2");
375  TRACE_REQUIRE_EQUAL(point.unit, "Units");
376  received_metrics_[2] = true;
377  }
378  if (point.metric == "Test Metric 3")
379  {
380  TRACE_REQUIRE_EQUAL(point.value, "3");
381  TRACE_REQUIRE_EQUAL(point.unit, "Units");
382  received_metrics_[3] = true;
383  }
384  if (point.metric == "Test Metric 4")
385  {
386  TRACE_REQUIRE_EQUAL(point.value, "4");
387  TRACE_REQUIRE_EQUAL(point.unit, "Units");
388  received_metrics_[4] = true;
389  }
390  if (point.metric == "Test Metric 5")
391  {
392  TRACE_REQUIRE_EQUAL(point.value, "5");
393  TRACE_REQUIRE_EQUAL(point.unit, "Units");
394  received_metrics_[5] = true;
395  }
396  if (point.metric == "Test Metric 6")
397  {
398  BOOST_TEST_FAIL("Metric level 6 should not have been sent!");
399  received_metrics_[6] = true;
400  }
401  if (point.metric == "Test Metric 7")
402  {
403  TRACE_REQUIRE_EQUAL(point.value, "7");
404  TRACE_REQUIRE_EQUAL(point.unit, "Units");
405  received_metrics_[7] = true;
406  }
407  if (point.metric == "Test Metric 8")
408  {
409  BOOST_TEST_FAIL("Metric level 8 should not have been sent!");
410  received_metrics_[8] = true;
411  }
412  if (point.metric == "Test Metric 9")
413  {
414  TRACE_REQUIRE_EQUAL(point.value, "9");
415  TRACE_REQUIRE_EQUAL(point.unit, "Units");
416  received_metrics_[9] = true;
417  }
418  if (point.metric == "Test Metric 10")
419  {
420  BOOST_TEST_FAIL("Metric level 10 should not have been sent!");
421  received_metrics_[10] = true;
422  }
423  }
424  TRACE_REQUIRE_EQUAL(received_metrics_.to_ulong(), 0x2BF);
425  artdaq::TestMetric::received_metrics.clear();
427  }
428 
429  mm.do_stop();
430  TRACE_REQUIRE_EQUAL(mm.Running(), false);
431  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
432 
433  mm.shutdown();
434  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
435  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics_Levels" << TLOG_ENDL;
436 }
437 
438 BOOST_AUTO_TEST_CASE(MetricFlood) // NOLINT(readability-function-size)
439 {
440  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST MetricFlood" << TLOG_ENDL;
442  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
443  TRACE_REQUIRE_EQUAL(mm.Running(), false);
444  TRACE_REQUIRE_EQUAL(mm.Active(), false);
445  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
446  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
447 
448  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 0.1 send_zeros: false} metric_send_maximum_delay_ms: 100";
449  fhicl::ParameterSet pset = artdaq::make_pset(testConfig);
450 
451  mm.initialize(pset, "MetricManager_t");
452  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
453  TRACE_REQUIRE_EQUAL(mm.Running(), false);
454  TRACE_REQUIRE_EQUAL(mm.Active(), false);
455 
456  mm.do_start();
457  TRACE_REQUIRE_EQUAL(mm.Running(), true);
458  TRACE_REQUIRE_EQUAL(mm.Active(), true);
459 
460  auto beforeOne = std::chrono::steady_clock::now();
461  mm.sendMetric("Test Metric 1", 1, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
462  auto afterOne = std::chrono::steady_clock::now();
463 
464  while (mm.metricManagerBusy())
465  {
466  usleep(1000);
467  }
468 
469  auto beforeTen = std::chrono::steady_clock::now();
470  for (auto ii = 1; ii <= 10; ++ii)
471  {
472  mm.sendMetric("Test Metric 10", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
473  }
474  auto afterTen = std::chrono::steady_clock::now();
475 
476  while (mm.metricManagerBusy())
477  {
478  usleep(1000);
479  }
480 
481  auto beforeOneHundred = std::chrono::steady_clock::now();
482  for (auto ii = 1; ii <= 100; ++ii)
483  {
484  mm.sendMetric("Test Metric 100", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
485  }
486  auto afterOneHundred = std::chrono::steady_clock::now();
487 
488  while (mm.metricManagerBusy())
489  {
490  usleep(1000);
491  }
492 
493  auto beforeOneThousand = std::chrono::steady_clock::now();
494  for (auto ii = 1; ii <= 1000; ++ii)
495  {
496  mm.sendMetric("Test Metric 1000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
497  }
498  auto afterOneThousand = std::chrono::steady_clock::now();
499 
500  while (mm.metricManagerBusy())
501  {
502  usleep(1000);
503  }
504 
505  auto beforeTenThousand = std::chrono::steady_clock::now();
506  for (auto ii = 1; ii <= 10000; ++ii)
507  {
508  mm.sendMetric("Test Metric 10000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
509  }
510  auto afterTenThousand = std::chrono::steady_clock::now();
511 
512  auto beforeStop = std::chrono::steady_clock::now();
513  mm.do_stop();
514  TRACE_REQUIRE_EQUAL(mm.Running(), false);
515  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
516  auto afterStop = std::chrono::steady_clock::now();
517 
518  TLOG_INFO("MetricManager_t") << "Time for One Metric: " << GetElapsedTime(beforeOne, afterOne) << " s." << TLOG_ENDL;
519  TLOG_INFO("MetricManager_t") << "Time for Ten Metrics: " << GetElapsedTime(beforeTen, afterTen) << " s." << TLOG_ENDL;
520  TLOG_INFO("MetricManager_t") << "Time for One Hundred Metrics: " << GetElapsedTime(beforeOneHundred, afterOneHundred)
521  << " s." << TLOG_ENDL;
522  TLOG_INFO("MetricManager_t") << "Time for One Thousand Metrics: "
523  << GetElapsedTime(beforeOneThousand, afterOneThousand) << " s." << TLOG_ENDL;
524  TLOG_INFO("MetricManager_t") << "Time for Ten Thousand Metrics: "
525  << GetElapsedTime(beforeTenThousand, afterTenThousand) << " s." << TLOG_ENDL;
526  TLOG_INFO("MetricManager_t") << "Time for Stop Metrics: " << GetElapsedTime(beforeStop, afterStop) << " s."
527  << TLOG_ENDL;
528 
529  mm.shutdown();
530  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
531  TLOG_DEBUG("MetricManager_t") << "END TEST MetricFlood" << TLOG_ENDL;
532 }
533 
534 BOOST_AUTO_TEST_SUITE_END()
void shutdown()
Call the destructors for all configured MetricPlugin instances.
void initialize(fhicl::ParameterSet const &pset, std::string const &prefix="")
Initialize the MetricPlugin instances.
bool Initialized()
Returns whether the MetricManager has been initialized (configured)
void sendMetric(std::string const &name, std::string const &value, std::string const &unit, int level, MetricMode mode, std::string const &metricPrefix="", bool useNameOverride=false)
Send a metric with the given parameters to any MetricPlugins with a threshold level &gt;= to level...
bool metricManagerBusy()
Determine whether the MetricManager or any of its plugins are currently processing metrics...
size_t metricQueueSize(std::string const &name="")
Return the size of the named metric queue
Report the sum of all values. Use for counters to report accurate results.
void do_start()
Perform startup actions for each configured MetricPlugin.
static void LockReceivedMetricMutex()
Lock the ReceivedMetricMutex
Definition: TestMetric.hh:36
static std::list< MetricPoint > received_metrics
List of received metric data.
Definition: TestMetric.hh:53
bool Running()
Returns whether the MetricManager is running (accepting metric calls)
void do_stop()
Stop sending metrics to the MetricPlugin instances.
fhicl::ParameterSet make_pset(std::string const &config_str)
Create a fhicl::ParameterSet from a string.
over. Use to create rates from counters.
Report only the last value recorded. Useful for event counters, run numbers, etc. ...
The MetricManager class handles loading metric plugins and asynchronously sending metric data to them...
static void UnlockReceivedMetricMutex()
Unlock the ReceivedMetricMutex
Definition: TestMetric.hh:46
bool Active()
Returns whether any Metric Plugins are defined and configured
bool metricQueueEmpty()
Returns whether the metric queue is completely empty
Report the average of all values. Use for rates to report accurate results.