-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from humanmade/backport-827-to-v17-branch
[Backport v17] Add Afterburner panel to QM
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* Altis Afterburner data collector for the Query Monitor plugin. | ||
*/ | ||
|
||
namespace Altis\Cloud\Afterburner; | ||
|
||
/** | ||
* Altis Config Qm Collector. | ||
*/ | ||
class QM_Collector extends \QM_Collector { | ||
|
||
/** | ||
* Collector ID. | ||
* | ||
* @var string | ||
*/ | ||
public $id = 'afterburner'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* Altis Afterburner data output for HTML pages in the Query Monitor plugin. | ||
* | ||
* @package altis/dev-tools | ||
*/ | ||
|
||
namespace Altis\Cloud\Afterburner; | ||
|
||
use Afterburner; | ||
use QM_Collector; | ||
|
||
/** | ||
* Altis Afterburner QM Panel Class. | ||
* | ||
* @package altis/dev-tools | ||
*/ | ||
class QM_Output_Html extends \QM_Output_Html { | ||
|
||
/** | ||
* Altis Config QM Panel Constructor. | ||
* | ||
* @param QM_Collector $collector Collector object. | ||
*/ | ||
public function __construct( QM_Collector $collector ) { | ||
parent::__construct( $collector ); | ||
add_filter( 'qm/output/menus', [ $this, 'admin_menu' ] ); | ||
} | ||
|
||
/** | ||
* Panel name. | ||
* | ||
* @return string | ||
*/ | ||
public function name() { | ||
return esc_html_x( 'Afterburner', 'Menu item name for the Query Monitor plugin', 'altis' ); | ||
} | ||
|
||
/** | ||
* Panel content. | ||
* | ||
* @return void | ||
*/ | ||
public function output() { | ||
$stats = Afterburner\ObjectCache\getStats(); | ||
?> | ||
<?php $this->before_tabular_output(); ?> | ||
|
||
<tbody> | ||
<tr> | ||
<td><?php echo esc_html__( 'Afterburner connection string', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( ini_get( 'afterburner.redis_server_info' ) ) ?></code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'redis_skip_server_check', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( ini_get( 'afterburner.redis_skip_server_check' ) ) ?></code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'Max items in LRU cache', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( ini_get( 'afterburner.lru_cache_max_items' ) ) ?></code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'Items in LRU cache for this PHP worker', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( $stats->lru_cache_items ) ?></code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'Total memory used in LRU cache for this PHP worker', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( size_format( $stats->lru_cache_size ) ) ?></code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'Redis total time (ms) for this PHP worker', 'altis' ); ?></td> | ||
<td><code><?php echo esc_html( round( $stats->redis_total_time / 1000 ) ) ?>ms</code></td> | ||
</tr> | ||
<tr> | ||
<td><?php echo esc_html__( 'All stats for this PHP worker', 'altis' ); ?></td> | ||
<td><pre><?php echo esc_html( print_r( $stats, true ) ) // phpcs:ignore ?></pre></td> | ||
</tbody> | ||
|
||
<?php | ||
$this->after_tabular_output(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Altis Afterburner namespace bootstrap file. | ||
*/ | ||
|
||
namespace Altis\Cloud\Afterburner; | ||
|
||
/** | ||
* Bootstrap function. | ||
*/ | ||
function bootstrap() : void { | ||
add_filter( 'qm/outputter/html', __NAMESPACE__ . '\\register_qm_output_html' ); | ||
} | ||
|
||
/** | ||
* Register the HTML outputter for the Xray panel | ||
* | ||
* @param array $output The HTML output for the collector | ||
* @return array | ||
*/ | ||
function register_qm_output_html( array $output ) : array { | ||
require_once __DIR__ . '/class-qm-output-html.php'; | ||
require_once __DIR__ . '/class-qm-collector.php'; | ||
|
||
$output['afterburner'] = new QM_Output_Html( new QM_Collector() ); | ||
|
||
return $output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters