Skip to content

Commit

Permalink
Update master (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Adrian Mörchen <[email protected]>
Co-authored-by: Duvergier Claude <[email protected]>
  • Loading branch information
3 people authored Mar 13, 2023
1 parent a2eade0 commit 414a7b0
Show file tree
Hide file tree
Showing 23 changed files with 778 additions and 554 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": {
"symfony/polyfill-php80": "^v1.23.1"
"symfony/polyfill-php80": "^v1.24.0",
"promphp/prometheus_client_php": "^2.6"
},
"autoload": {
"psr-4": {
Expand Down
89 changes: 78 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions includes/_legacy.prometheus_custom_metrics.php

This file was deleted.

63 changes: 34 additions & 29 deletions includes/classes/Default_Metrics_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace WP_Prometheus_Metrics;

use WP_Prometheus_Metrics\metrics\Database_Size_Metric;
use WP_Prometheus_Metrics\metrics\Info_Metric;
use WP_Prometheus_Metrics\metrics\Options_Autoloaded_Count_Metric;
use WP_Prometheus_Metrics\metrics\Options_Autoloaded_Size_Metric;
use WP_Prometheus_Metrics\metrics\Pending_Updates_Metric;
use WP_Prometheus_Metrics\metrics\Performance_Count_Posts_Metric;
use WP_Prometheus_Metrics\metrics\Performance_Write_File_To_WP_Upload_Dir_Metric;
use WP_Prometheus_Metrics\metrics\Performance_Write_Temp_File_Metric;
use WP_Prometheus_Metrics\metrics\Post_Types_Count_Metric;
use WP_Prometheus_Metrics\metrics\Posts_Without_Content_Metric;
Expand All @@ -15,33 +17,36 @@
use WP_Prometheus_Metrics\metrics\Users_Count_Metric;
use WP_Prometheus_Metrics\metrics\Users_Sessions_Metric;

class Default_Metrics_Loader {
private $metrics_loaded = false;

public function __construct() {
add_filter( 'prometheus_get_metrics', [ $this, 'load_default_metrics' ], 0 );
}


function load_default_metrics( $metrics = [] ) {
if ( ! $this->metrics_loaded ) {

new Database_Size_Metric();
new Users_Count_Metric();
new Users_Sessions_Metric();
new Options_Autoloaded_Count_Metric();
new Options_Autoloaded_Size_Metric();
new Posts_Without_Content_Metric();
new Posts_Without_Title_Metric();
new Post_Types_Count_Metric();
new Pending_Updates_Metric();
new Transients_Autoloaded_Count_Metric();
new Performance_Count_Posts_Metric();
new Performance_Write_Temp_File_Metric();

$this->metrics_loaded = true;
}

return $metrics;
}
class Default_Metrics_Loader
{
private $metrics_loaded = false;

public function __construct()
{
add_filter('prometheus-metrics-for-wp/get_metrics', [$this, 'load_default_metrics'], 0, 2);
}

function load_default_metrics($metrics = [])
{
if (!$this->metrics_loaded) {
new Database_Size_Metric();
new Info_Metric();
new Options_Autoloaded_Count_Metric();
new Options_Autoloaded_Size_Metric();
new Pending_Updates_Metric();
new Performance_Count_Posts_Metric();
new Performance_Write_File_To_WP_Upload_Dir_Metric();
new Performance_Write_Temp_File_Metric();
new Post_Types_Count_Metric();
new Posts_Without_Content_Metric();
new Posts_Without_Title_Metric();
new Transients_Autoloaded_Count_Metric();
new Users_Count_Metric();
new Users_Sessions_Metric();

$this->metrics_loaded = true;
}

return $metrics;
}
}
Loading

0 comments on commit 414a7b0

Please sign in to comment.