File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 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 ;
@@ -29,6 +30,7 @@ function load_default_metrics($metrics = [])
29
30
{
30
31
if (!$ this ->metrics_loaded ) {
31
32
new Database_Size_Metric ();
33
+ new Info_Metric ();
32
34
new Options_Autoloaded_Count_Metric ();
33
35
new Options_Autoloaded_Size_Metric ();
34
36
new Pending_Updates_Metric ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace WP_Prometheus_Metrics \metrics ;
4
+
5
+
6
+ /**
7
+ * A metric that gives information about the WordPress environment.
8
+ */
9
+ class Info_Metric extends Abstract_Gauge_Metric
10
+ {
11
+ public function __construct ()
12
+ {
13
+ parent ::__construct ('info ' );
14
+ }
15
+
16
+ public function get_metric_labels (): array
17
+ {
18
+ global $ wp_db_version ;
19
+
20
+ return array_merge (
21
+ parent ::get_metric_labels (),
22
+ [
23
+ 'version ' => get_bloginfo ('version ' ),
24
+ 'db_version ' => $ wp_db_version ,
25
+ ]
26
+ );
27
+ }
28
+
29
+ function get_metric_value ()
30
+ {
31
+ // This metric as no value, the interesting part is in it's labels.
32
+ // Returning a standard 1 value here.
33
+ return 1 ;
34
+ }
35
+
36
+ function get_help_text (): string
37
+ {
38
+ return _x ('Information about the WordPress environment ' , 'Metric Help Text ' , 'prometheus-metrics-for-wp ' );
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments