telemetry#
-
namespace heph
Functions
-
template<typename ...Args>
void log(LogLevel level, telemetry::MessageWithLocation &&msg, Args&&... fields) noexcept# Log a message. Example:
heph::log(heph::LogLevel::WARN, "speed is over limit", "current_speed", 31.3, "limit", 30.0, "entity", "km/h")
-
template<typename ...Args>
void log(LogLevel level, telemetry::MessageWithLocation &&msg) noexcept# Log a message without fields. Example:
heph::log(heph::LogLevel::WARN, "speed is over limit")
-
template<typename ...Args>
void logIf(LogLevel level, bool condition, telemetry::MessageWithLocation &&msg, Args&&... fields) noexcept# Conditionally log a message. Example:
heph::log(heph::LogLevel::WARN, a==3, "speed is over limit", "current_speed", 31.3, "limit", 30.0, "entity", "km/h")
-
template<typename ...Args>
void logIf(LogLevel level, bool condition, telemetry::MessageWithLocation &&msg) noexcept# Conditionally log a message without fields. Example:
heph::log(heph::LogLevel::WARN, a==3, "speed is over limit")
-
namespace telemetry#
-
template<typename ...Args>
-
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
Enums
-
namespace telemetry
-
template<typename T>
struct Field#
-
struct ILogSink#
- #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/347/execroot/_main/modules/telemetry/telemetry/include/hephaestus/telemetry/log_sink.h”
Interface for sinks that log entries can be sent to.
-
struct LogEntry#
- #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/347/execroot/_main/modules/telemetry/telemetry/include/hephaestus/telemetry/log_sink.h”
A class that allows easy composition of logs for structured logging. Example(see also log.cpp):
cpp namespace ht=heph::telemetry; log(LogLevel::INFO, "adding", "speed", 31.3, "tag", "test");
logs ‘level=info hostname=goofy location=log.h:123 thread-id=5124 time=2023-12-3T8:52:02+0 module=”my module” message=”adding” id=12345 speed=31.3 tag=”test”’ Remark: We would like to use libfmt with quoted formatting as proposed in fmtlib/fmt#825 once its included (instead of sstream).Public Types
Public Members
Public Functions
-
LogEntry(heph::LogLevel level, MessageWithLocation &&message)#
-
template<NonQuotable T>
inline LogEntry &&operator<<(const Field<T> &field)# General loginfo consumer, should be used like LogEntry(“my message”) << Field{“field”, 1234} Converted to string with stringstream.
- Template Parameters:
T – any type that is consumeable by stringstream
- Parameters:
key – identifier for the logging data
value – value of the logging data
- Returns:
LogEntry&&
-
template<Quotable S>
inline LogEntry &&operator<<(const Field<S> &field)# Specialized loginfo consumer for string types so that they are quoted, should be used like LogEntry(“my message”) << Field{“field”, “mystring”}.
- Template Parameters:
T – any type that is consumeable by stringstream
- Parameters:
key – identifier for the logging data
val – value of the logging data
- Returns:
LogEntry&&
-
LogEntry(heph::LogLevel level, MessageWithLocation &&message)#
-
struct MessageWithLocation#
- #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/347/execroot/_main/modules/telemetry/telemetry/include/hephaestus/telemetry/log_sink.h”
Wrapper around string literals to enhance them with a location. Note that the message is not owned by this class. We need to use a const char* here in order to enable implicit conversion from
log(LogLevel::INFO,"my string");
. The standard guarantees that string literals exist for the entirety of the program lifetime, so it is fine to use it asMessageWithLocation("my message");
-
template<typename T>
-
namespace telemetry
-
template<>
struct formatter<heph::telemetry::Field<std::string>> : public fmt::formatter<std::string_view>#
-
template<>
struct formatter<heph::telemetry::LogEntry> : public fmt::formatter<std::string_view># - #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/347/execroot/_main/modules/telemetry/telemetry/include/hephaestus/telemetry/log_sink.h”
Formatter for LogEntry adhering to logfmt rules.
-
namespace heph
-
namespace telemetry
-
class AbslLogSink : public heph::telemetry::ILogSink#
- #include “/home/runner/.bazel/sandbox/processwrapper-sandbox/347/execroot/_main/modules/telemetry/telemetry/include/hephaestus/telemetry/log_sinks/absl_sink.h”
A simple sink that passes the logs to ABSL. Per default entry is formatted via heph::telemetry::format.
-
class AbslLogSink : public heph::telemetry::ILogSink#
-
namespace telemetry