DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
OpMonPublisher.hpp
Go to the documentation of this file.
1
10
11#ifndef KAFKAOPMON_INCLUDE_KAFKAOPMON_OPMONPUBLISHER_HPP_
12#define KAFKAOPMON_INCLUDE_KAFKAOPMON_OPMONPUBLISHER_HPP_
13
14#include <ers/ers.hpp>
15#include <librdkafka/rdkafkacpp.h>
16#include <nlohmann/json.hpp>
17
18#include <memory>
19#include <string>
20
21#include "opmonlib/Utils.hpp"
23
24namespace dunedaq {
25
27 MissingParameter,
28 "No " << parameter << " in " << conf,
29 ((std::string)parameter)((std::string)conf))
30
33 "Invalid " << parameter << ", cause: " << reason,
34 ((std::string)parameter)((std::string)reason))
35
37 FailedProducerCreation,
38 "Failed creation of a Kafka producer, cause: " << reason,
39 ((std::string)reason))
40
42 FailedProduce,
43 "Failed produce of message with key " << key << ", cause: " << reason,
44 ((std::string)key)((std::string)reason))
45
47 TimeoutReachedWhileFlushing,
48 "Publisher destroyed before all messages were completed, timeout: " << timeout << " ms",
49 ((int)timeout))
50
51} // dunedaq namespace
52
54
56{
57
58public:
59 OpMonPublisher(const nlohmann::json& conf);
60
61 OpMonPublisher() = delete;
66
68
70
71protected:
72 std::string extract_topic(const dunedaq::opmon::OpMonEntry&) const noexcept { return m_default_topic; }
73 std::string extract_key(const dunedaq::opmon::OpMonEntry& e) const noexcept
74 {
75 return dunedaq::opmonlib::to_string(e.origin()) + '/' + e.measurement();
76 }
77
78private:
79 std::unique_ptr<RdKafka::Producer> m_producer;
80 std::string m_default_topic = "monitoring.opmon_stream";
81};
82
83} // namespace dunedaq::kafkaopmon
84
85#endif // KAFKAOPMON_INCLUDE_KAFKAOPMON_OPMONPUBLISHER_HPP_
OpMonPublisher(const nlohmann::json &conf)
std::unique_ptr< RdKafka::Producer > m_producer
OpMonPublisher & operator=(const OpMonPublisher &)=delete
std::string extract_key(const dunedaq::opmon::OpMonEntry &e) const noexcept
OpMonPublisher(const OpMonPublisher &)=delete
std::string extract_topic(const dunedaq::opmon::OpMonEntry &) const noexcept
void publish(dunedaq::opmon::OpMonEntry &&) const
OpMonPublisher(OpMonPublisher &&)=delete
OpMonPublisher & operator=(OpMonPublisher &&)=delete
std::string to_string(const dunedaq::opmon::OpMonId &)
Definition Utils.cpp:166
The DUNE-DAQ namespace.
ERS_DECLARE_ISSUE(cibmodules, CIBCommunicationError, " CIB Hardware Communication Error: "<< descriptor,((std::string) descriptor)) ERS_DECLARE_ISSUE(cibmodules