# solid-performance/1.4.0/src/Performance/Telemetry/Health_Data.php

Solid Performance – Your No-Code Caching, Performance, &amp; Page Speed Solution, version 1.4.0. 175 lines.

- Page: https://pluginprobe.com/plugins/solid-performance/1.4.0/code/src/Performance/Telemetry/Health_Data.php
- Raw: https://pluginprobe.com/plugins/solid-performance/1.4.0/raw/src/Performance/Telemetry/Health_Data.php
- Modified: 2025-02-12T22:54:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/solid-performance/1.4.0/code/src/Performance/Telemetry/Health_Data.php#L10-L20`.

```php
<?php
/**
 * Handles adding a new section to the site health data screen.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */

declare( strict_types=1 );

namespace SolidWP\Performance\Telemetry;

use RuntimeException;
use SolidWP\Performance\Page_Cache\Compression\Collection;
use SolidWP\Performance\Page_Cache\Compression\Contracts\Compressible;
use SolidWP\Performance\Preload\Limiter\Core_Counter;
use SolidWP\Performance\Preload\Limiter\Load\System_Load_Monitor;
use SolidWP\Performance\Preload\Preload_Mode_Manager;

/**
 * Handles adding a new section to the site health data screen.
 *
 * @since 0.1.0
 *
 * @package SolidWP\Performance
 */
class Health_Data {

	/**
	 * The collection of compression strategies.
	 *
	 * @var Collection
	 */
	private Collection $compressors;

	/**
	 * @var System_Load_Monitor
	 */
	private System_Load_Monitor $system_load_monitor;

	/**
	 * @var Core_Counter
	 */
	private Core_Counter $core_counter;

	/**
	 * @var Preload_Mode_Manager
	 */
	private Preload_Mode_Manager $preload_mode_manager;

	/**
	 * @param Collection           $compressors The collection of compression strategies.
	 * @param System_Load_Monitor  $system_load_monitor The system load monitor.
	 * @param Core_Counter         $core_counter The core counter.
	 * @param Preload_Mode_Manager $preload_mode_manager The preload mode manager.
	 */
	public function __construct(
		Collection $compressors,
		System_Load_Monitor $system_load_monitor,
		Core_Counter $core_counter,
		Preload_Mode_Manager $preload_mode_manager
	) {
		$this->compressors          = $compressors;
		$this->system_load_monitor  = $system_load_monitor;
		$this->core_counter         = $core_counter;
		$this->preload_mode_manager = $preload_mode_manager;
	}

	/**
	 * Adds a new Solid Performance section to site health data.
	 *
	 * @since 0.1.0
	 *
	 * @filter debug_information
	 *
	 * @param array $info The array of site health data.
	 *
	 * @return array
	 */
	public function add_summary_to_telemetry( array $info ): array {
		$page_cache          = swpsp_config_get( 'page_cache' );
		$page_cache_status   = $page_cache['enabled'] ? esc_html__( 'Enabled', 'LION' ) : esc_html__( 'Disabled', 'LION' );
		$cache_dir_writeable = swpsp_direct_filesystem()->is_writable( $page_cache['cache_dir'] ) ? esc_html__( 'Writable', 'LION' ) : esc_html__( 'Not Writable', 'LION' );
		$debug_mode_status   = $page_cache['debug'] ? esc_html__( 'Enabled', 'LION' ) : esc_html__( 'Disabled', 'LION' );
		$exclusion_count     = count( $page_cache['exclusions'] );
		$enabled_compressors = implode(
			', ',
			array_filter(
				array_map( static fn( Compressible $c ): string => $c->encoding(), $this->compressors->enabled() )
			)
		);

		try {
			$system_load       = [];
			$system_load_debug = [];
			$load_averages     = $this->system_load_monitor->load()->all();

			foreach ( $load_averages as $label => $load_average ) {
				$new_label = sprintf(
					/* translators: %s: The system load time, e.g. 1, 5, or 15. */
					_n(
						'%s min',
						'%s mins',
						$label,
						'LION'
					),
					$label
				);

				$formatted_average = number_format( $load_average, 2 );

				$system_load[ $new_label ]   = $formatted_average;
				$system_load_debug[ $label ] = $formatted_average;
			}
		} catch ( RuntimeException $e ) {
			$system_load       = $e->getMessage();
			$system_load_debug = $e->getMessage();
		}

		$core_count = $this->core_counter->core_count();

		$info['solid-performance'] = [
			'label'  => esc_html__( 'Solid Performance', 'LION' ),
			'fields' => [
				'page_cache_status'        => [
					'label' => esc_html__( 'Page cache', 'LION' ),
					'value' => $page_cache_status,
					'debug' => strtolower( $page_cache_status ),
				],
				'cache_directory'          => [
					'label' => esc_html__( 'Cache directory', 'LION' ),
					'value' => $page_cache['cache_dir'],
					'debug' => $page_cache['cache_dir'],
				],
				'cache_directory_writable' => [
					'label' => esc_html__( 'Cache directory permissions', 'LION' ),
					'value' => $cache_dir_writeable,
					'debug' => strtolower( $cache_dir_writeable ),
				],
				'debug_mode'               => [
					'label' => esc_html__( 'Debug mode', 'LION' ),
					'value' => $debug_mode_status,
					'debug' => strtolower( $debug_mode_status ),
				],
				'exclusion_count'          => [
					'label' => esc_html__( 'Number of custom exclusions', 'LION' ),
					'value' => $exclusion_count,
				],
				'compression'              => [
					'label' => esc_html__( 'Supported compression algorithms', 'LION' ),
					'value' => $enabled_compressors,
					'debug' => $enabled_compressors,
				],
				'system_load'              => [
					'label' => esc_html__( 'System load average', 'LION' ),
					'value' => $system_load,
					'debug' => $system_load_debug,
				],
				'core_count'               => [
					'label' => esc_html__( 'System CPU core count', 'LION' ),
					'value' => $core_count,
				],
				'high_performance_mode'    => [
					'label' => esc_html__( 'High performance mode', 'LION' ),
					'value' => $this->preload_mode_manager->is_high_performance_mode() ? esc_html__( 'Enabled', 'LION' ) : esc_html__( 'Disabled', 'LION' ),
					'debug' => $this->preload_mode_manager->is_high_performance_mode(),
				],
			],
		];

		return $info;
	}
}

```
