23#include <unordered_map>
50 static constexpr auto values = std::array{
56 static constexpr std::string_view module_name =
"monitoring_interface";
84 std::unordered_map<std::string, std::string>
tags;
90 ,
timestamp(std::chrono::system_clock::now()) {}
106 metrics.emplace_back(name, value);
122 std::chrono::system_clock::time_point
timestamp = std::chrono::system_clock::now();
158 std::chrono::system_clock::time_point
timestamp = std::chrono::system_clock::now();
188 std::chrono::system_clock::time_point
timestamp = std::chrono::system_clock::now();
221 static constexpr auto values = std::array{
227 static constexpr std::string_view module_name =
"monitoring_interface";
230namespace interfaces {
241 std::unordered_map<std::string, std::string>
metadata;
244 :
timestamp(std::chrono::system_clock::now()) {}
283 const std::string& name,
285 const std::unordered_map<std::string, std::string>& tags) = 0;
Result type for error handling with member function support.
Interface for modules that provide monitor implementations.
virtual std::shared_ptr< IMonitor > create_monitor(const std::string &name)=0
Create a new monitor with specific name.
virtual std::shared_ptr< IMonitor > get_monitor()=0
Get the default monitor instance.
virtual ~IMonitorProvider()=default
Standard interface for monitoring implementations.
virtual Result< health_check_result > check_health()=0
Perform health check.
virtual VoidResult record_metric(const std::string &name, double value)=0
Record a metric value.
virtual ~IMonitor()=default
virtual Result< metrics_snapshot > get_metrics()=0
Get current metrics snapshot.
virtual VoidResult reset()=0
Reset all metrics.
virtual VoidResult record_metric(const std::string &name, double value, const std::unordered_map< std::string, std::string > &tags)=0
Record a metric with tags.
Interface for objects that can be monitored.
virtual Result< health_check_result > health_check()=0
Check health status.
virtual std::string get_component_name() const =0
Get component name for monitoring.
virtual ~IMonitorable()=default
virtual Result< metrics_snapshot > get_monitoring_data()=0
Get monitoring data.
Generic enum serialization utilities using C++20 concepts.
health_status
Standard health status levels.
metric_type
Types of metrics supported by the monitoring system.
std::function< std::shared_ptr< IMonitor >()> MonitorFactory
Factory function type for creating monitor instances.
Result< metric_type > metric_type_from_string(const std::string &str)
Convert string to metric type.
std::string to_string(log_level level)
Convert log level to string.
Result< Enum > enum_from_string(std::string_view str)
Convert a string to its enum value (case-insensitive)
std::string enum_to_string(Enum value)
Convert an enum value to its string representation.
Umbrella header for Result<T> type and related utilities.
Primary template for enum traits (must be specialized for each enum)
Result of a health check operation.
bool is_operational() const
std::unordered_map< std::string, std::string > metadata
std::chrono::milliseconds check_duration
std::chrono::system_clock::time_point timestamp
Standard metric value structure with type information.
metric_value(const std::string &n="", double v=0.0, metric_type t=metric_type::gauge)
std::chrono::system_clock::time_point timestamp
std::unordered_map< std::string, std::string > tags
Complete snapshot of metrics at a point in time.
void add_metric(const std::string &name, double value)
std::chrono::system_clock::time_point capture_time
std::vector< metric_value > metrics
Specialized metrics for system-level monitoring.
metric_value cpu_usage_percent
metric_value memory_usage_bytes
std::vector< metric_value > to_metrics() const
Convert to vector of metric_value.
metric_value total_allocations
metric_value active_threads
std::chrono::system_clock::time_point timestamp
Specialized metrics for thread pool monitoring.
std::vector< metric_value > to_metrics() const
Convert to vector of metric_value.
metric_value jobs_pending
std::uint32_t pool_instance_id
thread_pool_metrics(const std::string &name, std::uint32_t instance_id=0)
metric_value idle_threads
metric_value worker_threads
metric_value total_execution_time_ns
thread_pool_metrics()=default
metric_value jobs_completed
std::chrono::system_clock::time_point timestamp
metric_value average_latency_ns
Specialized metrics for worker thread monitoring.
std::chrono::system_clock::time_point timestamp
metric_value jobs_processed
metric_value idle_time_ns
metric_value total_processing_time_ns
worker_metrics(std::size_t id)
metric_value context_switches
std::vector< metric_value > to_metrics() const
Convert to vector of metric_value.