253 [[nodiscard]] auto
is_healthy() const ->
bool;
308 [[nodiscard]] auto
to_json() const ->
std::
string;
386 std::vector<std::shared_ptr<execution_event_listener>>
listeners_;
Bottleneck detection and reporting for thread pool performance analysis.
Interface for receiving job execution events.
Comprehensive diagnostics API for thread pool monitoring.
auto check_queue_health() const -> component_health
Checks queue component health.
void generate_recommendations(bottleneck_report &report) const
Generates recommendations for a bottleneck.
auto get_active_jobs() const -> std::vector< job_info >
Gets currently executing jobs.
void add_event_listener(std::shared_ptr< execution_event_listener > listener)
Adds an event listener.
auto get_worker_info(const thread_worker &worker, std::size_t index) const -> thread_info
Gets thread info for a single worker.
auto to_json() const -> std::string
Exports diagnostics as JSON.
thread_pool_diagnostics & operator=(thread_pool_diagnostics &&)=delete
auto get_recent_jobs(std::size_t limit=100) const -> std::vector< job_info >
Gets recent completed/failed jobs.
diagnostics_config config_
Configuration for diagnostics.
~thread_pool_diagnostics()
Destructor.
auto to_prometheus() const -> std::string
Exports diagnostics as Prometheus-compatible metrics.
std::mutex listeners_mutex_
Mutex for event listeners.
std::vector< std::shared_ptr< execution_event_listener > > listeners_
Event listeners.
void record_job_completion(const job_info &info)
Records a job completion for history tracking.
thread_pool & pool_
Reference to the monitored thread pool.
auto detect_bottlenecks() const -> bottleneck_report
Analyzes for bottlenecks.
auto is_tracing_enabled() const -> bool
Checks if tracing is enabled.
auto check_metrics_health(double avg_latency_ms, double success_rate) const -> component_health
Checks metrics component health.
auto get_pending_jobs(std::size_t limit=100) const -> std::vector< job_info >
Gets pending jobs in queue.
auto get_config() const -> diagnostics_config
Gets the current configuration.
auto get_recent_events(std::size_t limit=100) const -> std::vector< job_execution_event >
Gets recent execution events.
thread_pool_diagnostics(const thread_pool_diagnostics &)=delete
std::mutex jobs_mutex_
Mutex for recent jobs access.
std::chrono::steady_clock::time_point start_time_
Time when the pool was started.
auto format_thread_dump() const -> std::string
Gets formatted thread dump (human-readable).
thread_pool_diagnostics(thread_pool &pool, const diagnostics_config &config={})
Constructs diagnostics for a thread pool.
void notify_listeners(const job_execution_event &event)
Notifies all event listeners.
auto to_string() const -> std::string
Exports diagnostics as formatted string.
void remove_event_listener(std::shared_ptr< execution_event_listener > listener)
Removes an event listener.
void enable_tracing(bool enable, std::size_t history_size=1000)
Enables or disables job execution tracing.
auto health_check() const -> health_status
Performs comprehensive health check.
std::atomic< bool > tracing_enabled_
Whether event tracing is enabled.
void record_event(const job_execution_event &event)
Records a job execution event.
thread_pool_diagnostics & operator=(const thread_pool_diagnostics &)=delete
auto is_healthy() const -> bool
Quick check if pool is healthy.
std::atomic< std::uint64_t > next_event_id_
Counter for event IDs.
std::deque< job_execution_event > event_history_
Ring buffer for event history.
std::mutex events_mutex_
Mutex for event history access.
auto dump_thread_states() const -> std::vector< thread_info >
Gets current state of all worker threads.
void set_config(const diagnostics_config &config)
Updates the configuration.
auto check_worker_health() const -> component_health
Checks worker component health.
thread_pool_diagnostics(thread_pool_diagnostics &&)=delete
std::deque< job_info > recent_jobs_
Ring buffer for recent job completions.
A thread pool for concurrent execution of jobs using multiple worker threads.
A specialized worker thread that processes jobs from a job_queue.
Job execution event types and listener interface for tracing.
Health status thresholds and monitoring for thread pools.
Job information snapshot for diagnostics and monitoring.
Core threading foundation of the thread system library.
@ info
Informational messages highlighting progress.
Analysis report of bottlenecks in the thread pool.
Health status of a single component.
Configuration options for thread pool diagnostics.
health_thresholds health_thresholds_config
Configurable thresholds for health status determination.
double queue_saturation_high
High watermark threshold for queue saturation (0.0 to 1.0).
std::size_t recent_jobs_capacity
Maximum number of recent jobs to track.
std::uint32_t event_sample_rate
Diagnostics event sampling rate (record every Nth job).
double wait_time_threshold_ms
Wait time threshold (ms) for slow consumer detection.
bool enable_tracing
Enable automatic event tracing.
std::size_t event_history_size
Maximum number of events to retain in history.
double utilization_high_threshold
Worker utilization threshold for bottleneck detection.
Comprehensive health status of the thread pool.
Configurable thresholds for health status determination.
Event data for job execution tracing.
Information about a job in the thread pool.
Information about a worker thread in the pool.
Worker thread state information for diagnostics.