You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -443,6 +443,33 @@ It should show the default values we defined for all options.
443
443
444
444
🚧 TODO
445
445
446
+
### Writing a custom exporter sub-plugin (optional)
447
+
448
+
Out of the box `tool_monitoring` only comes with a Prometheus [exporter](#exporter).
449
+
If you are using a different monitoring backend, you will need to provide a custom [exporter sub-plugin](#exporter-sub-plugins).
450
+
451
+
How exactly such a plugin should look depends heavily on the specifics of your monitoring backend.
452
+
For example, since Prometheus is a pull-based monitoring backend, the exporter provides a route/endpoint for Prometheus to periodically query.
453
+
454
+
In general, the only requirements for an exporter sub-plugin are
455
+
- the `version.php` as well as a minimal language file (as with any other plugin),
456
+
- and that the plugin is placed in the `exporter/` directory of `tool_monitoring`.
457
+
458
+
There is no common exporter interface, so you have maximum flexibility in the rest of the setup.
459
+
If you have admin settings to configure, a `settings.php` script placed in the plugin directory will have access to a dedicated `admin_settingpage` via the `$settings` variable.
460
+
That page will be added under _Plugins_ > _Admin tools_ > _Monitoring_ > _Available Exporters_ and named the same as the sub-plugin.
461
+
462
+
Since any exporter will need access to the actual metrics available in the system, at some point it should probably make use of the [`metrics_manager`][. metrics_manager].
463
+
Instantiating it and calling its `fetch` method will be enough in most cases.
464
+
That will store all [`registered_metric`][. registered_metric] instances in its `metrics` property.
465
+
466
+
To calculate and retrieve the current value(s) of a given metric, the associated `registered_metric` instance just needs to be iterated over.
467
+
Iteration will yield the [`metric_value`][. metric_value] objects.
468
+
469
+
> [!TIP]
470
+
> You can look at how the Prometheus exporter does this in its [`exporter`][. exporter] class.
471
+
> Its `export` method receives the `metrics_manager::$metrics` array as an argument after the route controller called `fetch` on the manager.
472
+
446
473
## Terminology
447
474
448
475
### Metric
@@ -544,7 +571,8 @@ For convenience, the static `metric::collect` method can be used as the [hook ca
544
571
545
572
To allow all metrics to be individually enabled/disabled and more [advanced metrics](#configurable-metrics-advanced) to have their own persistent configuration, each concrete metric is associated with a row in the `tool_monitoring_metrics` database table.
546
573
547
-
The `registered_metric` class is an internal wrapper for metrics managed by `tool_monitoring` and maps instances to rows in the database table.
574
+
The [`registered_metric`][. registered_metric] class is a wrapper for metrics managed by `tool_monitoring` and maps instances to rows in the database table.
575
+
It implements the `IteratorAggregate` interface and iterating over an instance will call the `calculate` method of the underlying `metric` and pass through the value(s).
548
576
549
577
### Central `metrics_manager`
550
578
@@ -590,13 +618,15 @@ You should have received a copy of the GNU General Public License along with `to
590
618
591
619
**Code, tests, and documentation written by and for humans.** 🚫🤖
0 commit comments