Page MenuHomePhabricator

Provide a way to use log events as metrics in MediaWiki core
Open, Needs TriagePublic


MediaWiki currently has two unrelated subsystems for logging/debugging related events: structured logging (via LoggerFactory and any PSR-3 compatible logger; we are slowly moving towards Monolog, see also T155552: Make Monolog the default debug processing layer and deprecate wfDebug* and LegacyLogger) and event counting (via StatsdDataFactory). This leads to awkward duplication or unavailability of metrics, and probably an unhealthy level of coupling to statsd. Conceptually these are both about processing of debug events, and the logging architecture is flexible enough that it should be able to take on both duties. Authentication metrics use a custom log event handler to increment statsd metrics and that worked reasonably well, so it might be worth moving that capability to core.

We could add a log handler which listens to events with a special key (say, 'metrics' => [ <metric key 1>, <metric key 2>, ... ]) and converts them into statsd hits. (AuthManagerStatsdHandler would then become a log processor instead of a log handler.) That way, developers would have to be aware of one less interface.

Or maybe we could just require/recommend that each log event have some sort of event key, and mapping those to metric names could happen in a more detached manner (that's how AuthManagerStatsdHandler works now).

Or maybe this is pointless overcomplication, given that the current system seems to work fine :) But I kind of like the idea of monitoring code living in a separate location and being easy to review.