artdaq_utilities  v1_05_06
MetricManager_t.cc
1 
2 #define TRACE_NAME "MetricManager_t"
3 #include "trace.h"
4 
5 #include "artdaq-utilities/Plugins/MetricManager.hh"
7 
8 #define BOOST_TEST_MODULES MetricManager_t
9 #include "cetlib/quiet_unit_test.hpp"
10 #include "cetlib_except/exception.h"
11 #include "fhiclcpp/make_ParameterSet.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;
61  fhicl::make_ParameterSet(testConfig, pset);
62 
63  mm.initialize(pset, "MetricManager_t");
64  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
65  TRACE_REQUIRE_EQUAL(mm.Running(), false);
66  TRACE_REQUIRE_EQUAL(mm.Active(), false);
67 
68  mm.do_start();
69  TRACE_REQUIRE_EQUAL(mm.Running(), true);
70  TRACE_REQUIRE_EQUAL(mm.Active(), true);
71  TLOG_DEBUG("MetricManager_t") << "END TEST Initialize" << TLOG_ENDL;
72 }
73 
74 BOOST_AUTO_TEST_CASE(Initialize_WithError)
75 {
76  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Initialize_WithError" << TLOG_ENDL;
78  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
79  TRACE_REQUIRE_EQUAL(mm.Running(), false);
80  TRACE_REQUIRE_EQUAL(mm.Active(), false);
81  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
82  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
83 
84  std::string testConfig = "err: { level: 5 metricPluginType: nonExistentPluginType reporting_interval: 1.0}";
85  fhicl::ParameterSet pset;
86  fhicl::make_ParameterSet(testConfig, pset);
87 
88  mm.initialize(pset, "MetricManager_t");
89  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
90  TRACE_REQUIRE_EQUAL(mm.Running(), false);
91 
92  mm.do_start();
93  TRACE_REQUIRE_EQUAL(mm.Running(), true);
94  TRACE_REQUIRE_EQUAL(mm.Active(), false);
95  TLOG_DEBUG("MetricManager_t") << "END TEST Initialize_WithError" << TLOG_ENDL;
96 }
97 
98 BOOST_AUTO_TEST_CASE(Shutdown)
99 {
100  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST Shutdown" << TLOG_ENDL;
102  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
103  TRACE_REQUIRE_EQUAL(mm.Running(), false);
104  TRACE_REQUIRE_EQUAL(mm.Active(), false);
105  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
106  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
107 
108  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 1.0}";
109  fhicl::ParameterSet pset;
110  fhicl::make_ParameterSet(testConfig, pset);
111 
112  mm.initialize(pset, "MetricManager_t");
113  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
114  TRACE_REQUIRE_EQUAL(mm.Running(), false);
115  TRACE_REQUIRE_EQUAL(mm.Active(), false);
116 
117  mm.do_start();
118  TRACE_REQUIRE_EQUAL(mm.Running(), true);
119  TRACE_REQUIRE_EQUAL(mm.Active(), true);
120 
121  mm.do_stop();
122  TRACE_REQUIRE_EQUAL(mm.Running(), false);
123  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
124 
125  mm.shutdown();
126  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
127  TLOG_DEBUG("MetricManager_t") << "END TEST Shutdown" << TLOG_ENDL;
128 }
129 
130 BOOST_AUTO_TEST_CASE(SendMetric_String)
131 {
132  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetric_String" << TLOG_ENDL;
134  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
135  TRACE_REQUIRE_EQUAL(mm.Running(), false);
136  TRACE_REQUIRE_EQUAL(mm.Active(), false);
137  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
138  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
139 
140  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 1.0}";
141  fhicl::ParameterSet pset;
142  fhicl::make_ParameterSet(testConfig, pset);
143 
144  mm.initialize(pset, "MetricManager_t");
145  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
146  TRACE_REQUIRE_EQUAL(mm.Running(), false);
147  TRACE_REQUIRE_EQUAL(mm.Active(), false);
148 
149  mm.do_start();
150  TRACE_REQUIRE_EQUAL(mm.Running(), true);
151  TRACE_REQUIRE_EQUAL(mm.Active(), true);
152 
153  mm.sendMetric("Test Metric", "This is a test", "Units", 2, artdaq::MetricMode::LastPoint);
154 
155  mm.do_stop();
156  TRACE_REQUIRE_EQUAL(mm.Running(), false);
157  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
158 
159  mm.shutdown();
160  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
161  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetric_String" << TLOG_ENDL;
162 }
163 
164 BOOST_AUTO_TEST_CASE(SendMetrics) // NOLINT(readability-function-size)
165 {
166  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetrics" << TLOG_ENDL;
168  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
169  TRACE_REQUIRE_EQUAL(mm.Running(), false);
170  TRACE_REQUIRE_EQUAL(mm.Active(), false);
171  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
172  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
173 
174  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";
175  fhicl::ParameterSet pset;
176  fhicl::make_ParameterSet(testConfig, pset);
177 
178  mm.initialize(pset, "MetricManager_t");
179  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
180  TRACE_REQUIRE_EQUAL(mm.Running(), false);
181  TRACE_REQUIRE_EQUAL(mm.Active(), false);
182 
183  mm.do_start();
184  TRACE_REQUIRE_EQUAL(mm.Running(), true);
185  TRACE_REQUIRE_EQUAL(mm.Active(), true);
186 
187  mm.sendMetric("Test Metric LastPoint", 1, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
188  mm.sendMetric("Test Metric LastPoint", 5, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
189  while (mm.metricManagerBusy())
190  {
191  usleep(1000);
192  }
193 
194  {
196  bool present = false;
197  for (auto& point : artdaq::TestMetric::received_metrics)
198  {
199  TLOG(TLVL_DEBUG) << "Metric: " << point.metric << ", Value: " << point.value << ", Units: " << point.unit;
200  if (point.metric == "Test Metric LastPoint")
201  {
202  TRACE_REQUIRE_EQUAL(point.value, "5");
203  TRACE_REQUIRE_EQUAL(point.unit, "Units");
204  present = true;
205  }
206  }
207  BOOST_REQUIRE(present);
208  artdaq::TestMetric::received_metrics.clear();
210  }
211 
212  mm.sendMetric("Test Metric Accumulate", 4, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
213  mm.sendMetric("Test Metric Accumulate", 5, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
214  while (mm.metricManagerBusy())
215  {
216  usleep(1000);
217  }
218 
219  {
221  bool present = false;
222  for (auto& point : artdaq::TestMetric::received_metrics)
223  {
224  if (point.metric == "Test Metric Accumulate")
225  {
226  TRACE_REQUIRE_EQUAL(point.value, "9");
227  TRACE_REQUIRE_EQUAL(point.unit, "Units");
228  present = true;
229  }
230  }
231  BOOST_REQUIRE(present);
232  artdaq::TestMetric::received_metrics.clear();
234  }
235 
236  mm.sendMetric("Test Metric Average", 1, "Units", 2, artdaq::MetricMode::Average, "", true);
237  mm.sendMetric("Test Metric Average", 3, "Units", 2, artdaq::MetricMode::Average, "", true);
238  while (mm.metricManagerBusy())
239  {
240  usleep(1000);
241  }
242 
243  {
245  bool present = false;
246  for (auto& point : artdaq::TestMetric::received_metrics)
247  {
248  if (point.metric == "Test Metric Average")
249  {
250  TRACE_REQUIRE_EQUAL(std::stof(point.value), 2);
251  TRACE_REQUIRE_EQUAL(point.unit, "Units");
252  present = true;
253  }
254  }
255  BOOST_REQUIRE(present);
256  artdaq::TestMetric::received_metrics.clear();
258  }
259 
260  mm.sendMetric("Test Metric Rate", 4, "Units", 2, artdaq::MetricMode::Rate, "", true);
261  mm.sendMetric("Test Metric Rate", 5, "Units", 2, artdaq::MetricMode::Rate, "", true);
262  while (mm.metricManagerBusy())
263  {
264  usleep(1000);
265  }
266 
267  {
269  bool present = false;
270  for (auto& point : artdaq::TestMetric::received_metrics)
271  {
272  if (point.metric == "Test Metric Rate")
273  {
274  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
275  present = true;
276  }
277  }
278  BOOST_REQUIRE(present);
279  artdaq::TestMetric::received_metrics.clear();
281  }
282 
283  mm.sendMetric("Test Metric AccumulateAndRate", 4, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
284  mm.sendMetric("Test Metric AccumulateAndRate", 5, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
285  while (mm.metricManagerBusy())
286  {
287  usleep(1000);
288  }
289 
290  {
292  int present = 0;
293  for (auto& point : artdaq::TestMetric::received_metrics)
294  {
295  if (point.metric == "Test Metric AccumulateAndRate - Total")
296  {
297  TRACE_REQUIRE_EQUAL(point.value, "9");
298  TRACE_REQUIRE_EQUAL(point.unit, "Units");
299  present++;
300  }
301  if (point.metric == "Test Metric AccumulateAndRate - Rate")
302  {
303  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
304  present++;
305  }
306  }
307  TRACE_REQUIRE_EQUAL(present, 2);
308  artdaq::TestMetric::received_metrics.clear();
310  }
311 
312  mm.do_stop();
313  TRACE_REQUIRE_EQUAL(mm.Running(), false);
314  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
315 
316  mm.shutdown();
317  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
318  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics" << TLOG_ENDL;
319 }
320 
321 BOOST_AUTO_TEST_CASE(SendMetrics_Levels) // NOLINT(readability-function-size)
322 {
323  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetrics_Levels" << TLOG_ENDL;
325  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
326  TRACE_REQUIRE_EQUAL(mm.Running(), false);
327  TRACE_REQUIRE_EQUAL(mm.Active(), false);
328  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
329  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
330 
331  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";
332  fhicl::ParameterSet pset;
333  fhicl::make_ParameterSet(testConfig, pset);
334 
335  mm.initialize(pset, "MetricManager_t");
336  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
337  TRACE_REQUIRE_EQUAL(mm.Running(), false);
338  TRACE_REQUIRE_EQUAL(mm.Active(), false);
339 
340  mm.do_start();
341  TRACE_REQUIRE_EQUAL(mm.Running(), true);
342  TRACE_REQUIRE_EQUAL(mm.Active(), true);
343 
344  mm.sendMetric("Test Metric 0", 0, "Units", 0, artdaq::MetricMode::LastPoint, "", true);
345  mm.sendMetric("Test Metric 1", 1, "Units", 1, artdaq::MetricMode::LastPoint, "", true);
346  mm.sendMetric("Test Metric 2", 2, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
347  mm.sendMetric("Test Metric 3", 3, "Units", 3, artdaq::MetricMode::LastPoint, "", true);
348  mm.sendMetric("Test Metric 4", 4, "Units", 4, artdaq::MetricMode::LastPoint, "", true);
349  mm.sendMetric("Test Metric 5", 5, "Units", 5, artdaq::MetricMode::LastPoint, "", true);
350  mm.sendMetric("Test Metric 6", 6, "Units", 6, artdaq::MetricMode::LastPoint, "", true);
351  mm.sendMetric("Test Metric 7", 7, "Units", 7, artdaq::MetricMode::LastPoint, "", true);
352  mm.sendMetric("Test Metric 8", 8, "Units", 8, artdaq::MetricMode::LastPoint, "", true);
353  mm.sendMetric("Test Metric 9", 9, "Units", 9, artdaq::MetricMode::LastPoint, "", true);
354  mm.sendMetric("Test Metric 10", 10, "Units", 10, artdaq::MetricMode::LastPoint, "", true);
355  std::bitset<11> received_metrics_;
356 
357  while (mm.metricManagerBusy())
358  {
359  usleep(1000);
360  }
361 
362  {
364  for (auto& point : artdaq::TestMetric::received_metrics)
365  {
366  if (point.metric == "Test Metric 0")
367  {
368  TRACE_REQUIRE_EQUAL(point.value, "0");
369  TRACE_REQUIRE_EQUAL(point.unit, "Units");
370  received_metrics_[0] = true;
371  }
372  if (point.metric == "Test Metric 1")
373  {
374  TRACE_REQUIRE_EQUAL(point.value, "1");
375  TRACE_REQUIRE_EQUAL(point.unit, "Units");
376  received_metrics_[1] = true;
377  }
378  if (point.metric == "Test Metric 2")
379  {
380  TRACE_REQUIRE_EQUAL(point.value, "2");
381  TRACE_REQUIRE_EQUAL(point.unit, "Units");
382  received_metrics_[2] = true;
383  }
384  if (point.metric == "Test Metric 3")
385  {
386  TRACE_REQUIRE_EQUAL(point.value, "3");
387  TRACE_REQUIRE_EQUAL(point.unit, "Units");
388  received_metrics_[3] = true;
389  }
390  if (point.metric == "Test Metric 4")
391  {
392  TRACE_REQUIRE_EQUAL(point.value, "4");
393  TRACE_REQUIRE_EQUAL(point.unit, "Units");
394  received_metrics_[4] = true;
395  }
396  if (point.metric == "Test Metric 5")
397  {
398  TRACE_REQUIRE_EQUAL(point.value, "5");
399  TRACE_REQUIRE_EQUAL(point.unit, "Units");
400  received_metrics_[5] = true;
401  }
402  if (point.metric == "Test Metric 6")
403  {
404  BOOST_TEST_FAIL("Metric level 6 should not have been sent!");
405  received_metrics_[6] = true;
406  }
407  if (point.metric == "Test Metric 7")
408  {
409  TRACE_REQUIRE_EQUAL(point.value, "7");
410  TRACE_REQUIRE_EQUAL(point.unit, "Units");
411  received_metrics_[7] = true;
412  }
413  if (point.metric == "Test Metric 8")
414  {
415  BOOST_TEST_FAIL("Metric level 8 should not have been sent!");
416  received_metrics_[8] = true;
417  }
418  if (point.metric == "Test Metric 9")
419  {
420  TRACE_REQUIRE_EQUAL(point.value, "9");
421  TRACE_REQUIRE_EQUAL(point.unit, "Units");
422  received_metrics_[9] = true;
423  }
424  if (point.metric == "Test Metric 10")
425  {
426  BOOST_TEST_FAIL("Metric level 10 should not have been sent!");
427  received_metrics_[10] = true;
428  }
429  }
430  TRACE_REQUIRE_EQUAL(received_metrics_.to_ulong(), 0x2BF);
431  artdaq::TestMetric::received_metrics.clear();
433  }
434 
435  mm.do_stop();
436  TRACE_REQUIRE_EQUAL(mm.Running(), false);
437  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
438 
439  mm.shutdown();
440  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
441  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics_Levels" << TLOG_ENDL;
442 }
443 
444 BOOST_AUTO_TEST_CASE(MetricFlood) // NOLINT(readability-function-size)
445 {
446  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST MetricFlood" << TLOG_ENDL;
448  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
449  TRACE_REQUIRE_EQUAL(mm.Running(), false);
450  TRACE_REQUIRE_EQUAL(mm.Active(), false);
451  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
452  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
453 
454  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 0.1 send_zeros: false} metric_send_maximum_delay_ms: 100";
455  fhicl::ParameterSet pset;
456  fhicl::make_ParameterSet(testConfig, pset);
457 
458  mm.initialize(pset, "MetricManager_t");
459  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
460  TRACE_REQUIRE_EQUAL(mm.Running(), false);
461  TRACE_REQUIRE_EQUAL(mm.Active(), false);
462 
463  mm.do_start();
464  TRACE_REQUIRE_EQUAL(mm.Running(), true);
465  TRACE_REQUIRE_EQUAL(mm.Active(), true);
466 
467  auto beforeOne = std::chrono::steady_clock::now();
468  mm.sendMetric("Test Metric 1", 1, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
469  auto afterOne = std::chrono::steady_clock::now();
470 
471  while (mm.metricManagerBusy())
472  {
473  usleep(1000);
474  }
475 
476  auto beforeTen = std::chrono::steady_clock::now();
477  for (auto ii = 1; ii <= 10; ++ii)
478  {
479  mm.sendMetric("Test Metric 10", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
480  }
481  auto afterTen = std::chrono::steady_clock::now();
482 
483  while (mm.metricManagerBusy())
484  {
485  usleep(1000);
486  }
487 
488  auto beforeOneHundred = std::chrono::steady_clock::now();
489  for (auto ii = 1; ii <= 100; ++ii)
490  {
491  mm.sendMetric("Test Metric 100", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
492  }
493  auto afterOneHundred = std::chrono::steady_clock::now();
494 
495  while (mm.metricManagerBusy())
496  {
497  usleep(1000);
498  }
499 
500  auto beforeOneThousand = std::chrono::steady_clock::now();
501  for (auto ii = 1; ii <= 1000; ++ii)
502  {
503  mm.sendMetric("Test Metric 1000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
504  }
505  auto afterOneThousand = std::chrono::steady_clock::now();
506 
507  while (mm.metricManagerBusy())
508  {
509  usleep(1000);
510  }
511 
512  auto beforeTenThousand = std::chrono::steady_clock::now();
513  for (auto ii = 1; ii <= 10000; ++ii)
514  {
515  mm.sendMetric("Test Metric 10000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
516  }
517  auto afterTenThousand = std::chrono::steady_clock::now();
518 
519  auto beforeStop = std::chrono::steady_clock::now();
520  mm.do_stop();
521  TRACE_REQUIRE_EQUAL(mm.Running(), false);
522  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
523  auto afterStop = std::chrono::steady_clock::now();
524 
525  TLOG_INFO("MetricManager_t") << "Time for One Metric: " << GetElapsedTime(beforeOne, afterOne) << " s." << TLOG_ENDL;
526  TLOG_INFO("MetricManager_t") << "Time for Ten Metrics: " << GetElapsedTime(beforeTen, afterTen) << " s." << TLOG_ENDL;
527  TLOG_INFO("MetricManager_t") << "Time for One Hundred Metrics: " << GetElapsedTime(beforeOneHundred, afterOneHundred)
528  << " s." << TLOG_ENDL;
529  TLOG_INFO("MetricManager_t") << "Time for One Thousand Metrics: "
530  << GetElapsedTime(beforeOneThousand, afterOneThousand) << " s." << TLOG_ENDL;
531  TLOG_INFO("MetricManager_t") << "Time for Ten Thousand Metrics: "
532  << GetElapsedTime(beforeTenThousand, afterTenThousand) << " s." << TLOG_ENDL;
533  TLOG_INFO("MetricManager_t") << "Time for Stop Metrics: " << GetElapsedTime(beforeStop, afterStop) << " s."
534  << TLOG_ENDL;
535 
536  mm.shutdown();
537  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
538  TLOG_DEBUG("MetricManager_t") << "END TEST MetricFlood" << TLOG_ENDL;
539 }
540 
541 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.
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.