|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
Comprehensive health status of the thread pool. More...
#include <health_status.h>

Public Member Functions | |
| auto | is_operational () const -> bool |
| Checks if the thread pool is operational. | |
| auto | is_healthy () const -> bool |
| Checks if the thread pool is fully healthy. | |
| auto | http_status_code () const -> int |
| Gets HTTP status code for this health status. | |
| auto | find_component (const std::string &name) const -> const component_health * |
| Finds a component by name. | |
| auto | calculate_overall_status () -> void |
| Calculates overall status from component states. | |
| auto | to_json () const -> std::string |
| Converts health status to JSON string. | |
| auto | to_string () const -> std::string |
| Converts health status to human-readable string. | |
| auto | to_prometheus (const std::string &pool_name="default") const -> std::string |
| Converts health status to Prometheus-compatible metrics format. | |
Public Attributes | |
| health_state | overall_status {health_state::unknown} |
| Overall health state of the thread pool. | |
| std::string | status_message |
| Human-readable message about overall status. | |
| std::chrono::steady_clock::time_point | check_time |
| Time when this health check was performed. | |
| std::vector< component_health > | components |
| Health status of individual components. | |
| double | uptime_seconds {0.0} |
| Time since the thread pool was started (seconds). | |
| std::uint64_t | total_jobs_processed {0} |
| Total number of jobs processed since startup. | |
| double | success_rate {1.0} |
| Job success rate (0.0 to 1.0). | |
| double | avg_latency_ms {0.0} |
| Average job latency in milliseconds. | |
| std::size_t | active_workers {0} |
| Number of active workers. | |
| std::size_t | total_workers {0} |
| Total number of workers. | |
| std::size_t | queue_depth {0} |
| Current queue depth. | |
| std::size_t | queue_capacity {0} |
| Queue capacity (if bounded). | |
Comprehensive health status of the thread pool.
Contains overall health status, individual component health, and summary metrics. Designed to be compatible with standard health check frameworks and easily serializable to JSON.
This structure is designed to integrate with:
Definition at line 205 of file health_status.h.
|
inline |
Calculates overall status from component states.
Updates overall_status based on component health:
Definition at line 334 of file health_status.h.
References components, kcenon::thread::diagnostics::degraded, kcenon::thread::diagnostics::healthy, overall_status, status_message, kcenon::thread::diagnostics::unhealthy, and kcenon::thread::diagnostics::unknown.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check().

|
inlinenodiscard |
Finds a component by name.
| name | Component name to search for. |
Definition at line 312 of file health_status.h.
References components.
|
inlinenodiscard |
Gets HTTP status code for this health status.
Definition at line 302 of file health_status.h.
References kcenon::thread::diagnostics::health_state_to_http_code(), and overall_status.
Referenced by to_json(), and to_string().


|
inlinenodiscard |
Checks if the thread pool is fully healthy.
Definition at line 293 of file health_status.h.
References kcenon::thread::diagnostics::healthy, and overall_status.
|
inlinenodiscard |
Checks if the thread pool is operational.
Definition at line 283 of file health_status.h.
References kcenon::thread::diagnostics::degraded, kcenon::thread::diagnostics::healthy, and overall_status.
|
inlinenodiscard |
Converts health status to JSON string.
Output format is compatible with standard health check endpoints and monitoring tools like Kubernetes, Spring Boot Actuator, etc.
Definition at line 399 of file health_status.h.
References active_workers, avg_latency_ms, components, kcenon::thread::diagnostics::health_state_to_string(), http_status_code(), overall_status, queue_capacity, queue_depth, status_message, success_rate, total_jobs_processed, total_workers, and uptime_seconds.

|
inlinenodiscard |
Converts health status to Prometheus-compatible metrics format.
Produces metrics in Prometheus exposition format suitable for scraping by Prometheus or compatible monitoring systems.
| pool_name | Name of the thread pool for metric labels. |
Output format:
Definition at line 542 of file health_status.h.
References active_workers, avg_latency_ms, components, kcenon::thread::diagnostics::degraded, kcenon::thread::diagnostics::healthy, overall_status, queue_capacity, queue_depth, success_rate, total_jobs_processed, total_workers, and uptime_seconds.
|
inlinenodiscard |
Converts health status to human-readable string.
Provides a formatted text representation suitable for logging or console output.
Definition at line 481 of file health_status.h.
References active_workers, avg_latency_ms, components, kcenon::thread::diagnostics::health_state_to_string(), http_status_code(), overall_status, queue_capacity, queue_depth, status_message, success_rate, total_jobs_processed, total_workers, and uptime_seconds.

| std::size_t kcenon::thread::diagnostics::health_status::active_workers {0} |
Number of active workers.
Definition at line 258 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| double kcenon::thread::diagnostics::health_status::avg_latency_ms {0.0} |
Average job latency in milliseconds.
Definition at line 253 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| std::chrono::steady_clock::time_point kcenon::thread::diagnostics::health_status::check_time |
Time when this health check was performed.
Definition at line 224 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check().
| std::vector<component_health> kcenon::thread::diagnostics::health_status::components |
Health status of individual components.
Definition at line 229 of file health_status.h.
Referenced by calculate_overall_status(), find_component(), kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| health_state kcenon::thread::diagnostics::health_status::overall_status {health_state::unknown} |
Overall health state of the thread pool.
Aggregated from all component health states. If any component is unhealthy, overall is unhealthy. If any component is degraded, overall is degraded.
Definition at line 214 of file health_status.h.
Referenced by calculate_overall_status(), http_status_code(), is_healthy(), is_operational(), to_json(), to_prometheus(), and to_string().
| std::size_t kcenon::thread::diagnostics::health_status::queue_capacity {0} |
Queue capacity (if bounded).
Definition at line 273 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| std::size_t kcenon::thread::diagnostics::health_status::queue_depth {0} |
Current queue depth.
Definition at line 268 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| std::string kcenon::thread::diagnostics::health_status::status_message |
Human-readable message about overall status.
Definition at line 219 of file health_status.h.
Referenced by calculate_overall_status(), to_json(), and to_string().
| double kcenon::thread::diagnostics::health_status::success_rate {1.0} |
Job success rate (0.0 to 1.0).
Definition at line 248 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| std::uint64_t kcenon::thread::diagnostics::health_status::total_jobs_processed {0} |
Total number of jobs processed since startup.
Definition at line 243 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| std::size_t kcenon::thread::diagnostics::health_status::total_workers {0} |
Total number of workers.
Definition at line 263 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().
| double kcenon::thread::diagnostics::health_status::uptime_seconds {0.0} |
Time since the thread pool was started (seconds).
Definition at line 238 of file health_status.h.
Referenced by kcenon::thread::diagnostics::thread_pool_diagnostics::health_check(), to_json(), to_prometheus(), and to_string().