artdaq_utilities  v1_05_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_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 typedef std::chrono::duration<double, std::ratio<1>> seconds;
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)
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()) usleep(1000);
190 
191  {
193  bool present = false;
194  for (auto& point : artdaq::TestMetric::received_metrics)
195  {
196  TLOG(TLVL_DEBUG) << "Metric: " << point.metric << ", Value: " << point.value << ", Units: " << point.unit;
197  if (point.metric == "Test Metric LastPoint")
198  {
199  TRACE_REQUIRE_EQUAL(point.value, "5");
200  TRACE_REQUIRE_EQUAL(point.unit, "Units");
201  present = true;
202  }
203  }
204  BOOST_REQUIRE(present);
205  artdaq::TestMetric::received_metrics.clear();
207  }
208 
209  mm.sendMetric("Test Metric Accumulate", 4, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
210  mm.sendMetric("Test Metric Accumulate", 5, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
211  while (mm.metricManagerBusy()) usleep(1000);
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()) usleep(1000);
233 
234  {
236  bool present = false;
237  for (auto& point : artdaq::TestMetric::received_metrics)
238  {
239  if (point.metric == "Test Metric Average")
240  {
241  TRACE_REQUIRE_EQUAL(std::stof(point.value), 2);
242  TRACE_REQUIRE_EQUAL(point.unit, "Units");
243  present = true;
244  }
245  }
246  BOOST_REQUIRE(present);
247  artdaq::TestMetric::received_metrics.clear();
249  }
250 
251  mm.sendMetric("Test Metric Rate", 4, "Units", 2, artdaq::MetricMode::Rate, "", true);
252  mm.sendMetric("Test Metric Rate", 5, "Units", 2, artdaq::MetricMode::Rate, "", true);
253  while (mm.metricManagerBusy()) usleep(1000);
254 
255  {
257  bool present = false;
258  for (auto& point : artdaq::TestMetric::received_metrics)
259  {
260  if (point.metric == "Test Metric Rate")
261  {
262  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
263  present = true;
264  }
265  }
266  BOOST_REQUIRE(present);
267  artdaq::TestMetric::received_metrics.clear();
269  }
270 
271  mm.sendMetric("Test Metric AccumulateAndRate", 4, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
272  mm.sendMetric("Test Metric AccumulateAndRate", 5, "Units", 2, artdaq::MetricMode::Accumulate | artdaq::MetricMode::Rate, "", true);
273  while (mm.metricManagerBusy()) usleep(1000);
274 
275  {
277  int present = 0;
278  for (auto& point : artdaq::TestMetric::received_metrics)
279  {
280  if (point.metric == "Test Metric AccumulateAndRate - Total")
281  {
282  TRACE_REQUIRE_EQUAL(point.value, "9");
283  TRACE_REQUIRE_EQUAL(point.unit, "Units");
284  present++;
285  }
286  if (point.metric == "Test Metric AccumulateAndRate - Rate")
287  {
288  TRACE_REQUIRE_EQUAL(point.unit, "Units/s");
289  present++;
290  }
291  }
292  TRACE_REQUIRE_EQUAL(present, 2);
293  artdaq::TestMetric::received_metrics.clear();
295  }
296 
297  mm.do_stop();
298  TRACE_REQUIRE_EQUAL(mm.Running(), false);
299  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
300 
301  mm.shutdown();
302  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
303  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics" << TLOG_ENDL;
304 }
305 
306 BOOST_AUTO_TEST_CASE(SendMetrics_Levels)
307 {
308  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST SendMetrics_Levels" << TLOG_ENDL;
310  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
311  TRACE_REQUIRE_EQUAL(mm.Running(), false);
312  TRACE_REQUIRE_EQUAL(mm.Active(), false);
313  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
314  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
315 
316  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";
317  fhicl::ParameterSet pset;
318  fhicl::make_ParameterSet(testConfig, pset);
319 
320  mm.initialize(pset, "MetricManager_t");
321  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
322  TRACE_REQUIRE_EQUAL(mm.Running(), false);
323  TRACE_REQUIRE_EQUAL(mm.Active(), false);
324 
325  mm.do_start();
326  TRACE_REQUIRE_EQUAL(mm.Running(), true);
327  TRACE_REQUIRE_EQUAL(mm.Active(), true);
328 
329  mm.sendMetric("Test Metric 0", 0, "Units", 0, artdaq::MetricMode::LastPoint, "", true);
330  mm.sendMetric("Test Metric 1", 1, "Units", 1, artdaq::MetricMode::LastPoint, "", true);
331  mm.sendMetric("Test Metric 2", 2, "Units", 2, artdaq::MetricMode::LastPoint, "", true);
332  mm.sendMetric("Test Metric 3", 3, "Units", 3, artdaq::MetricMode::LastPoint, "", true);
333  mm.sendMetric("Test Metric 4", 4, "Units", 4, artdaq::MetricMode::LastPoint, "", true);
334  mm.sendMetric("Test Metric 5", 5, "Units", 5, artdaq::MetricMode::LastPoint, "", true);
335  mm.sendMetric("Test Metric 6", 6, "Units", 6, artdaq::MetricMode::LastPoint, "", true);
336  mm.sendMetric("Test Metric 7", 7, "Units", 7, artdaq::MetricMode::LastPoint, "", true);
337  mm.sendMetric("Test Metric 8", 8, "Units", 8, artdaq::MetricMode::LastPoint, "", true);
338  mm.sendMetric("Test Metric 9", 9, "Units", 9, artdaq::MetricMode::LastPoint, "", true);
339  mm.sendMetric("Test Metric 10", 10, "Units", 10, artdaq::MetricMode::LastPoint, "", true);
340  std::bitset<11> received_metrics_;
341 
342  while (mm.metricManagerBusy()) usleep(1000);
343 
344  {
346  for (auto& point : artdaq::TestMetric::received_metrics)
347  {
348  if (point.metric == "Test Metric 0")
349  {
350  TRACE_REQUIRE_EQUAL(point.value, "0");
351  TRACE_REQUIRE_EQUAL(point.unit, "Units");
352  received_metrics_[0] = true;
353  }
354  if (point.metric == "Test Metric 1")
355  {
356  TRACE_REQUIRE_EQUAL(point.value, "1");
357  TRACE_REQUIRE_EQUAL(point.unit, "Units");
358  received_metrics_[1] = true;
359  }
360  if (point.metric == "Test Metric 2")
361  {
362  TRACE_REQUIRE_EQUAL(point.value, "2");
363  TRACE_REQUIRE_EQUAL(point.unit, "Units");
364  received_metrics_[2] = true;
365  }
366  if (point.metric == "Test Metric 3")
367  {
368  TRACE_REQUIRE_EQUAL(point.value, "3");
369  TRACE_REQUIRE_EQUAL(point.unit, "Units");
370  received_metrics_[3] = true;
371  }
372  if (point.metric == "Test Metric 4")
373  {
374  TRACE_REQUIRE_EQUAL(point.value, "4");
375  TRACE_REQUIRE_EQUAL(point.unit, "Units");
376  received_metrics_[4] = true;
377  }
378  if (point.metric == "Test Metric 5")
379  {
380  TRACE_REQUIRE_EQUAL(point.value, "5");
381  TRACE_REQUIRE_EQUAL(point.unit, "Units");
382  received_metrics_[5] = true;
383  }
384  if (point.metric == "Test Metric 6")
385  {
386  BOOST_TEST_FAIL("Metric level 6 should not have been sent!");
387  received_metrics_[6] = true;
388  }
389  if (point.metric == "Test Metric 7")
390  {
391  TRACE_REQUIRE_EQUAL(point.value, "7");
392  TRACE_REQUIRE_EQUAL(point.unit, "Units");
393  received_metrics_[7] = true;
394  }
395  if (point.metric == "Test Metric 8")
396  {
397  BOOST_TEST_FAIL("Metric level 8 should not have been sent!");
398  received_metrics_[8] = true;
399  }
400  if (point.metric == "Test Metric 9")
401  {
402  TRACE_REQUIRE_EQUAL(point.value, "9");
403  TRACE_REQUIRE_EQUAL(point.unit, "Units");
404  received_metrics_[9] = true;
405  }
406  if (point.metric == "Test Metric 10")
407  {
408  BOOST_TEST_FAIL("Metric level 10 should not have been sent!");
409  received_metrics_[10] = true;
410  }
411  }
412  TRACE_REQUIRE_EQUAL(received_metrics_.to_ulong(), 0x2BF);
413  artdaq::TestMetric::received_metrics.clear();
415  }
416 
417  mm.do_stop();
418  TRACE_REQUIRE_EQUAL(mm.Running(), false);
419  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
420 
421  mm.shutdown();
422  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
423  TLOG_DEBUG("MetricManager_t") << "END TEST SendMetrics_Levels" << TLOG_ENDL;
424 }
425 
426 BOOST_AUTO_TEST_CASE(MetricFlood)
427 {
428  TLOG_DEBUG("MetricManager_t") << "BEGIN TEST MetricFlood" << TLOG_ENDL;
430  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
431  TRACE_REQUIRE_EQUAL(mm.Running(), false);
432  TRACE_REQUIRE_EQUAL(mm.Active(), false);
433  TRACE_REQUIRE_EQUAL(mm.metricQueueEmpty(), true);
434  TRACE_REQUIRE_EQUAL(mm.metricQueueSize(), 0);
435 
436  std::string testConfig = "msgFac: { level: 5 metricPluginType: test reporting_interval: 0.1 send_zeros: false} metric_send_maximum_delay_ms: 100";
437  fhicl::ParameterSet pset;
438  fhicl::make_ParameterSet(testConfig, pset);
439 
440  mm.initialize(pset, "MetricManager_t");
441  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
442  TRACE_REQUIRE_EQUAL(mm.Running(), false);
443  TRACE_REQUIRE_EQUAL(mm.Active(), false);
444 
445  mm.do_start();
446  TRACE_REQUIRE_EQUAL(mm.Running(), true);
447  TRACE_REQUIRE_EQUAL(mm.Active(), true);
448 
449  auto beforeOne = std::chrono::steady_clock::now();
450  mm.sendMetric("Test Metric 1", 1, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
451  auto afterOne = std::chrono::steady_clock::now();
452 
453  while (mm.metricManagerBusy()) usleep(1000);
454 
455  auto beforeTen = std::chrono::steady_clock::now();
456  for (auto ii = 1; ii <= 10; ++ii)
457  {
458  mm.sendMetric("Test Metric 10", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
459  }
460  auto afterTen = std::chrono::steady_clock::now();
461 
462  while (mm.metricManagerBusy()) usleep(1000);
463 
464  auto beforeOneHundred = std::chrono::steady_clock::now();
465  for (auto ii = 1; ii <= 100; ++ii)
466  {
467  mm.sendMetric("Test Metric 100", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
468  }
469  auto afterOneHundred = std::chrono::steady_clock::now();
470 
471  while (mm.metricManagerBusy()) usleep(1000);
472 
473  auto beforeOneThousand = std::chrono::steady_clock::now();
474  for (auto ii = 1; ii <= 1000; ++ii)
475  {
476  mm.sendMetric("Test Metric 1000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
477  }
478  auto afterOneThousand = std::chrono::steady_clock::now();
479 
480  while (mm.metricManagerBusy()) usleep(1000);
481 
482  auto beforeTenThousand = std::chrono::steady_clock::now();
483  for (auto ii = 1; ii <= 10000; ++ii)
484  {
485  mm.sendMetric("Test Metric 10000", ii, "Units", 2, artdaq::MetricMode::Accumulate, "", true);
486  }
487  auto afterTenThousand = std::chrono::steady_clock::now();
488 
489  auto beforeStop = std::chrono::steady_clock::now();
490  mm.do_stop();
491  TRACE_REQUIRE_EQUAL(mm.Running(), false);
492  TRACE_REQUIRE_EQUAL(mm.Initialized(), true);
493  auto afterStop = std::chrono::steady_clock::now();
494 
495  TLOG_INFO("MetricManager_t") << "Time for One Metric: " << GetElapsedTime(beforeOne, afterOne) << " s." << TLOG_ENDL;
496  TLOG_INFO("MetricManager_t") << "Time for Ten Metrics: " << GetElapsedTime(beforeTen, afterTen) << " s." << TLOG_ENDL;
497  TLOG_INFO("MetricManager_t") << "Time for One Hundred Metrics: " << GetElapsedTime(beforeOneHundred, afterOneHundred)
498  << " s." << TLOG_ENDL;
499  TLOG_INFO("MetricManager_t") << "Time for One Thousand Metrics: "
500  << GetElapsedTime(beforeOneThousand, afterOneThousand) << " s." << TLOG_ENDL;
501  TLOG_INFO("MetricManager_t") << "Time for Ten Thousand Metrics: "
502  << GetElapsedTime(beforeTenThousand, afterTenThousand) << " s." << TLOG_ENDL;
503  TLOG_INFO("MetricManager_t") << "Time for Stop Metrics: " << GetElapsedTime(beforeStop, afterStop) << " s."
504  << TLOG_ENDL;
505 
506  mm.shutdown();
507  TRACE_REQUIRE_EQUAL(mm.Initialized(), false);
508  TLOG_DEBUG("MetricManager_t") << "END TEST MetricFlood" << TLOG_ENDL;
509 }
510 
511 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.