libstatistics_collector
master
Lightweight aggregation utilities to collect statistics and measure message metrics.
|
Go to the documentation of this file.
15 #ifndef LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_AGE_HPP_
16 #define LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_AGE_HPP_
21 #include <type_traits>
29 #include "rcutils/logging_macros.h"
33 namespace topic_statistics_collector
40 template<
typename M,
typename =
void>
48 struct HasHeader<M, decltype((void) M::header)>: std::true_type {};
56 template<
typename M,
typename Enable =
void>
59 static std::pair<bool, int64_t>
value(
const M &)
61 return std::make_pair(
false, 0);
71 struct TimeStamp<M, typename std::enable_if<HasHeader<M>::value>::type>
73 static std::pair<bool, int64_t>
value(
const M & m)
75 const auto stamp = m.header.stamp;
76 const auto nanos = RCL_S_TO_NS(
static_cast<int64_t
>(stamp.sec)) + stamp.nanosec;
77 return std::make_pair(
true, nanos);
101 const T & received_message,
102 const rcl_time_point_value_t now_nanoseconds)
override
106 if (timestamp_from_header.first) {
108 if (timestamp_from_header.second && now_nanoseconds) {
109 const std::chrono::nanoseconds age_nanos{now_nanoseconds - timestamp_from_header.second};
110 const auto age_millis = std::chrono::duration_cast<std::chrono::milliseconds>(age_nanos);
152 #endif // LIBSTATISTICS_COLLECTOR__TOPIC_STATISTICS_COLLECTOR__RECEIVED_MESSAGE_AGE_HPP_
std::string GetMetricUnit() const override
Definition: received_message_age.hpp:132
void OnMessageReceived(const T &received_message, const rcl_time_point_value_t now_nanoseconds) override
Definition: received_message_age.hpp:100
Definition: topic_statistics_collector.hpp:37
ReceivedMessageAgeCollector()=default
bool SetupStart() override
Definition: received_message_age.hpp:138
Definition: collector.hpp:29
constexpr const char kMillisecondUnitName[]
Definition: constants.hpp:29
std::string GetMetricName() const override
Definition: received_message_age.hpp:122
Definition: received_message_age.hpp:87
virtual ~ReceivedMessageAgeCollector()=default
bool SetupStop() override
Definition: received_message_age.hpp:143
constexpr const char kMsgAgeStatName[]
Definition: constants.hpp:27
static std::pair< bool, int64_t > value(const M &m)
Definition: received_message_age.hpp:73
virtual void AcceptData(const double measurement)
static std::pair< bool, int64_t > value(const M &)
Definition: received_message_age.hpp:59
Definition: received_message_age.hpp:57