7 #include "TRACE/tracemf.h"
8 #define TRACE_NAME (app_name_ + "_msgfacility_metric").c_str()
10 #include "artdaq-utilities/Plugins/MetricMacros.hh"
11 #include "fhiclcpp/ParameterSet.h"
12 #include "messagefacility/MessageLogger/MessageLogger.h"
25 std::string facility_;
48 explicit MsgFacilityMetric(fhicl::ParameterSet
const& config, std::string
const& app_name, std::string
const& metric_name)
50 , facility_(config.get<std::string>(
"output_message_category_name",
"ARTDAQ Metric"))
55 outputLevel_ = config.get<
int>(
"output_message_severity", 0);
57 catch (
const cet::exception&)
59 auto levelString = config.get<std::string>(
"output_message_severity",
"Info");
60 if (levelString ==
"Info" || levelString ==
"info" || levelString ==
"LogInfo")
64 else if (levelString ==
"Debug" || levelString ==
"debug" || levelString ==
"LogDebug")
68 else if (levelString ==
"Warning" || levelString ==
"warning" || levelString ==
"LogWarning" || levelString ==
"Warn" || levelString ==
"warn")
72 else if (levelString ==
"Error" || levelString ==
"error" || levelString ==
"LogError")
88 std::string
getLibName()
const override {
return "msgFacility"; }
98 void sendMetric_(
const std::string& name,
const std::string& value,
const std::string& unit,
const std::chrono::system_clock::time_point&)
override
102 switch (outputLevel_)
105 mf::LogInfo(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
108 mf::LogDebug(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
111 mf::LogWarning(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
114 mf::LogError(facility_) << name <<
": " << value <<
" " << unit <<
"." << std::endl;
127 void sendMetric_(
const std::string& name,
const int& value,
const std::string& unit,
const std::chrono::system_clock::time_point& time)
override
129 sendMetric_(name, std::to_string(value), unit, time);
139 void sendMetric_(
const std::string& name,
const double& value,
const std::string& unit,
const std::chrono::system_clock::time_point& time)
override
141 sendMetric_(name, std::to_string(value), unit, time);
151 void sendMetric_(
const std::string& name,
const float& value,
const std::string& unit,
const std::chrono::system_clock::time_point& time)
override
153 sendMetric_(name, std::to_string(value), unit, time);
163 void sendMetric_(
const std::string& name,
const uint64_t& value,
const std::string& unit,
const std::chrono::system_clock::time_point& time)
override
165 sendMetric_(name, std::to_string(value), unit, time);
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 float &value, const std::string &unit, const std::chrono::system_clock::time_point &time) override
Send a metric to MessageFacility. All metrics are converted to strings.
std::string getLibName() const override
Return the library name of the MetricPlugin.
MsgFacilityMetric(fhicl::ParameterSet const &config, std::string const &app_name, std::string const &metric_name)
MsgFacilityMetric Constructor.
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, const std::chrono::system_clock::time_point &) override
Send a metric to MessageFacilty. Format is: "name: value unit.".
void startMetrics_() override
Perform startup actions. No-Op.
void sendMetric_(const std::string &name, const double &value, const std::string &unit, const std::chrono::system_clock::time_point &time) override
Send a metric to MessageFacility. All metrics are converted to strings.
void sendMetric_(const std::string &name, const uint64_t &value, const std::string &unit, const std::chrono::system_clock::time_point &time) override
Send a metric to MessageFacility. All metrics are converted to strings.
void sendMetric_(const std::string &name, const int &value, const std::string &unit, const std::chrono::system_clock::time_point &time) override
Send a metric to MessageFacility. All metrics are converted to strings.
A MetricPlugin class which sends metric data to MessageFacility.
~MsgFacilityMetric() override
MsgFacilityMetric Destructor. Calls stopMetrics()
bool inhibit_
Flag to indicate that the MetricPlugin is being stopped, and any metric back-ends which do not have a...