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