metrics#
-
namespace heph
-
namespace telemetry
Functions
-
void registerMetricSink(std::unique_ptr<IMetricSink> sink)#
Register a new metric sink. For every metric recorded, the sink will be called to consume the data. There is no limit on the number of sinks supported.
-
void record(Metric metric)#
Record a metric. The metric is forwarded to all registered sinks. Sinks process the metric in a dedicated thread, this means that this function is non-blocking and deterministic.
-
template<typename DataT>
void record(std::string component, std::string tag, DataT &&data, ClockT::time_point timestamp = ClockT::now())# Record a user defined metric. NOTE: the data needs to be serializable to JSON. For details on how to achieve this, see
heph::serdes::serializeToJSON.- Parameters:
component – The component that is logging the metric_record, e.g. SLAM, Navigation, etc.
tag – The tag of the metric_record used to identify who created it, e.g. “front_camera”, “motor1”, etc.
data – The data to record, needs to be json serializable.
timestamp – The timestamp of the metric, if not provided, the current time is used.
-
void flushMetrics()#
-
void registerMetricSink(std::unique_ptr<IMetricSink> sink)#
-
namespace telemetry
-
namespace heph
-
namespace telemetry
-
namespace metric_sinks#
-
class TerminalMetricSink : public heph::telemetry::IMetricSink#
-
class TerminalMetricSink : public heph::telemetry::IMetricSink#
-
namespace metric_sinks#
-
namespace telemetry
-
namespace heph
-
namespace telemetry
-
template<typename ClockT = std::chrono::steady_clock>
class ScopedDurationRecorder# - #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/341/execroot/_main/modules/telemetry/metrics/include/hephaestus/telemetry/metrics/metric_scope.h”
Helper class to compute a scope time duration and add it to a Metric. The duration is added upon destruction of the scope. Example usage:
The above code creates the following metrics entry:{ Metric metric{ .component = "component", .tag = "tag", .timestamp = now, .values = {}, }; { auto _ = ScopedDurationRecorder{metric, "key"}; // code to measure } metric.addKeyValue("key.value_key", 42); }
”key.value_key” : 42
”key.elapsed_s” : <elapsed time in seconds>
Public Functions
-
inline ~ScopedDurationRecorder()#
-
ScopedDurationRecorder(const ScopedDurationRecorder&) = delete#
-
ScopedDurationRecorder(ScopedDurationRecorder&&) = delete#
- ScopedDurationRecorder &=delete operator= (const ScopedDurationRecorder &)
- ScopedDurationRecorder &=delete operator= (ScopedDurationRecorder &&)
-
struct ScopedMetric : public heph::telemetry::Metric#
- #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/341/execroot/_main/modules/telemetry/metrics/include/hephaestus/telemetry/metrics/metric_scope.h”
ScopedMetric is an extension for Metric that publish itself upon destruction. Example usage:
The above code records the following metric entries:{ ScopedMetric publisher{{ .component = "component", .tag = "tag", .timestamp = now, .values = {}; }}; auto* metric = publisher.metric(); addKeyValue(*metric, "key.value", 42); { ScopedDurationRecorder recorder{*metric, "key"}; } }
”key.value” : 42
”key.elapsed_s” : <elapsed time in seconds>
Public Functions
-
inline ~ScopedMetric()#
-
ScopedMetric(const ScopedMetric&) = delete#
-
ScopedMetric(ScopedMetric&&) = delete#
- ScopedMetric &=delete operator= (const ScopedMetric &)
- ScopedMetric &=delete operator= (ScopedMetric &&)
-
template<typename ClockT = std::chrono::steady_clock>
-
namespace telemetry
-
namespace heph
-
namespace telemetry
-
namespace telemetry