|
3 | 3 | namespace WP_Prometheus_Metrics;
|
4 | 4 |
|
5 | 5 | use WP_Prometheus_Metrics\metrics\Database_Size_Metric;
|
| 6 | +use WP_Prometheus_Metrics\metrics\Info_Metric; |
6 | 7 | use WP_Prometheus_Metrics\metrics\Options_Autoloaded_Count_Metric;
|
7 | 8 | use WP_Prometheus_Metrics\metrics\Options_Autoloaded_Size_Metric;
|
8 | 9 | use WP_Prometheus_Metrics\metrics\Pending_Updates_Metric;
|
9 | 10 | use WP_Prometheus_Metrics\metrics\Performance_Count_Posts_Metric;
|
| 11 | +use WP_Prometheus_Metrics\metrics\Performance_Write_File_To_WP_Upload_Dir_Metric; |
10 | 12 | use WP_Prometheus_Metrics\metrics\Performance_Write_Temp_File_Metric;
|
11 | 13 | use WP_Prometheus_Metrics\metrics\Post_Types_Count_Metric;
|
12 | 14 | use WP_Prometheus_Metrics\metrics\Posts_Without_Content_Metric;
|
|
15 | 17 | use WP_Prometheus_Metrics\metrics\Users_Count_Metric;
|
16 | 18 | use WP_Prometheus_Metrics\metrics\Users_Sessions_Metric;
|
17 | 19 |
|
18 |
| -class Default_Metrics_Loader { |
19 |
| - private $metrics_loaded = false; |
20 |
| - |
21 |
| - public function __construct() { |
22 |
| - add_filter( 'prometheus_get_metrics', [ $this, 'load_default_metrics' ], 0 ); |
23 |
| - } |
24 |
| - |
25 |
| - |
26 |
| - function load_default_metrics( $metrics = [] ) { |
27 |
| - if ( ! $this->metrics_loaded ) { |
28 |
| - |
29 |
| - new Database_Size_Metric(); |
30 |
| - new Users_Count_Metric(); |
31 |
| - new Users_Sessions_Metric(); |
32 |
| - new Options_Autoloaded_Count_Metric(); |
33 |
| - new Options_Autoloaded_Size_Metric(); |
34 |
| - new Posts_Without_Content_Metric(); |
35 |
| - new Posts_Without_Title_Metric(); |
36 |
| - new Post_Types_Count_Metric(); |
37 |
| - new Pending_Updates_Metric(); |
38 |
| - new Transients_Autoloaded_Count_Metric(); |
39 |
| - new Performance_Count_Posts_Metric(); |
40 |
| - new Performance_Write_Temp_File_Metric(); |
41 |
| - |
42 |
| - $this->metrics_loaded = true; |
43 |
| - } |
44 |
| - |
45 |
| - return $metrics; |
46 |
| - } |
| 20 | +class Default_Metrics_Loader |
| 21 | +{ |
| 22 | + private $metrics_loaded = false; |
| 23 | + |
| 24 | + public function __construct() |
| 25 | + { |
| 26 | + add_filter('prometheus-metrics-for-wp/get_metrics', [$this, 'load_default_metrics'], 0, 2); |
| 27 | + } |
| 28 | + |
| 29 | + function load_default_metrics($metrics = []) |
| 30 | + { |
| 31 | + if (!$this->metrics_loaded) { |
| 32 | + new Database_Size_Metric(); |
| 33 | + new Info_Metric(); |
| 34 | + new Options_Autoloaded_Count_Metric(); |
| 35 | + new Options_Autoloaded_Size_Metric(); |
| 36 | + new Pending_Updates_Metric(); |
| 37 | + new Performance_Count_Posts_Metric(); |
| 38 | + new Performance_Write_File_To_WP_Upload_Dir_Metric(); |
| 39 | + new Performance_Write_Temp_File_Metric(); |
| 40 | + new Post_Types_Count_Metric(); |
| 41 | + new Posts_Without_Content_Metric(); |
| 42 | + new Posts_Without_Title_Metric(); |
| 43 | + new Transients_Autoloaded_Count_Metric(); |
| 44 | + new Users_Count_Metric(); |
| 45 | + new Users_Sessions_Metric(); |
| 46 | + |
| 47 | + $this->metrics_loaded = true; |
| 48 | + } |
| 49 | + |
| 50 | + return $metrics; |
| 51 | + } |
47 | 52 | }
|
0 commit comments