7 #include "artdaq-utilities/Plugins/MetricMacros.hh"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "messagefacility/MessageLogger/MessageLogger.h"
22 std::string facility_;
46 , facility_(config.get<std::string>(
"output_message_category_name",
"ARTDAQ Metric"))
51 outputLevel_ = config.get<
int>(
"output_message_severity", 0);
53 catch (
const cet::exception&)
55 auto levelString = config.get<std::string>(
"output_message_severity",
"Info");
56 if (levelString ==
"Info" || levelString ==
"info" || levelString ==
"LogInfo")
60 else if (levelString ==
"Debug" || levelString ==
"debug" || levelString ==
"LogDebug")
64 else if (levelString ==
"Warning" || levelString ==
"warning" || levelString ==
"LogWarning" || levelString ==
"Warn" || levelString ==
"warn")
68 else if (levelString ==
"Error" || levelString ==
"error" || levelString ==
"LogError")
84 std::string
getLibName()
const override {
return "msgFacility"; }
92 void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit)
override
99 mf::LogInfo(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
102 mf::LogDebug(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
105 mf::LogWarning(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
108 mf::LogError(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
120 void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit)
override
131 void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit)
override
142 void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit)
override
153 void sendMetric_(
const std::string& name,
const uint64_t& value,
const std::string& unit)
override
void sendMetric_(const std::string &name, const uint64_t &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
The MetricPlugin class defines the interface that MetricManager uses to send metric data to the vario...
void startMetrics()
Perform startup actions. Simply calls the virtual startMetrics_ function.
void sendMetric_(const std::string &name, const int &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
std::string getLibName() const override
Return the library name of the MetricPlugin.
void sendMetric_(const std::string &name, const float &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
void stopMetrics()
Perform shutdown actions. Zeroes out all accumulators, and sends zeros for each metric. Calls stopMetrics_() for any plugin-defined shutdown actions.
void stopMetrics_() override
Perform shutdown actions. No-Op.
void sendMetric_(const std::string &name, const std::string &value, const std::string &unit) override
Send a metric to MessageFacilty. Format is: "name: value unit.".
void startMetrics_() override
Perform startup actions. No-Op.
MsgFacilityMetric(fhicl::ParameterSet const &config, std::string const &app_name)
MsgFacilityMetric Constructor.
A MetricPlugin class which sends metric data to MessageFacility.
~MsgFacilityMetric() override
MsgFacilityMetric Destructor. Calls stopMetrics()
void sendMetric_(const std::string &name, const double &value, const std::string &unit) override
Send a metric to MessageFacility. All metrics are converted to strings.
bool inhibit_
Flag to indicate that the MetricPlugin is being stopped, and any metric back-ends which do not have a...