4#include <prometheus/counter.h>
5#include <prometheus/gauge.h>
6#include <prometheus/info.h>
7#include <prometheus/summary.h>
14 throw std::invalid_argument(
"Can't init ZeroMQ statistics. Registry is null");
17 const auto name = prependName.empty() ?
"zeromq_" : prependName +
"_zeromq_";
24 &prometheus::BuildInfo().Name(name.substr(0, name.size() - 1)).Help(
"ZeroMQ server information").Register(*reg);
26 _infoFamily->Add({{
"init_time", date::format(
"%FT%TZ", date::floor<std::chrono::nanoseconds>(
27 std::chrono::high_resolution_clock::now()))}});
28 _infoFamily->Add({{
"performance_unit",
"nanoseconds"}});
32 .Name(name +
"succeeded_command_parts")
33 .Help(
"Number of received succeeded message parts")
37 .Name(name +
"failed_command_parts")
38 .Help(
"Number of received failed message parts")
42 .Name(name +
"total_command_parts")
43 .Help(
"Number of received total message parts")
49 &prometheus::BuildCounter().Name(name +
"uploaded_bytes").Help(
"Total uploaded bytes").Register(*reg).Add({});
51 .Name(name +
"downloaded_bytes")
52 .Help(
"Total downloaded bytes")
63 for (
const auto &entry : recvMsgs)
78 for (
const auto &entry : sendMsgs)
void consumeBaseStats(uint64_t succeeded, uint64_t failed, double processingTime)
void initBaseStats(const std::shared_ptr< prometheus::Registry > ®, const std::string &name)
prometheus::Counter * _failedCommandParts
Number of received failed message parts.
prometheus::Counter * _totalDownloadBytes
Total downloaded bytes.
void consumeStats(const std::vector< zmq::message_t > &recvMsgs, const std::vector< zmq::message_t > &sendMsgs, const ZeroMQServerStats &serverStats)
ZeroMQStats(const std::shared_ptr< prometheus::Registry > ®, const std::string &prependName="")
prometheus::Counter * _totalCommandParts
Number of received total message parts.
prometheus::Counter * _succeededCommandParts
Number of received succeeded message parts.
prometheus::Counter * _totalUploadBytes
Total uploaded bytes.
prometheus::Family< prometheus::Info > * _infoFamily
Information metric family.
bool isSuccessful
Indicates if processing was successful for this connection.
std::chrono::high_resolution_clock::time_point processingTimeEnd
Processing time end.
std::chrono::high_resolution_clock::time_point processingTimeStart
Processing time start.