Page MenuHomePhabricator

Allow a stream to register interest in multiple events more easily
Closed, ResolvedPublic

Description

Background

Currently, if an instrumentor wants to register interest in all events that an instrument dispatches, then they have to list all of those events verbatim. This is both inflexible and error prone.

For example, consider the example stream config in https://phabricator.wikimedia.org/T309013#7953227:

LocalSettings.php
// ...

'events' => [
  'dt.init',
  'dt.ready',
  'dt.loaded',
  'dt.first_change',
  'dt.save_intent',
  'dt.save_attempt',
  'dt.save_success',
  'dt.save_failure',
  'dt.abort',
],

// ...

It should be possible to write the above using a shorthand, e.g.:

LocalSettings.php
// ...

'events' => [
  'dt.',
],

// ...

Notes

  1. It would be better for everyone involved if we copy the semantics of other partial or wildcard subscription mechanisms familiar to Wikimedia developers. With that in mind, I propose that we copy the semantics of mw.trackSubscribe( t, callback ), which subscribes the callback to events on all topics starting with t, i.e.
mw.trackSubscribe( 'foo', topic => console.log( topic ) );

mw.track( 'foo' ); // => "foo"
mw.track( 'fooo' ); // => "fooo"
mw.track( 'foo2' ); // => "foo2"
mw.track( 'foo.bar' ); // => "foo.bar"

mw.track( 'fo' ); // NOP

Event Timeline

phuedx renamed this task from Allow a stream to register interest in multiple events to Allow a stream to register interest in multiple events more simply .May 26 2022, 4:25 PM
phuedx renamed this task from Allow a stream to register interest in multiple events more simply to Allow a stream to register interest in multiple events more easily .May 27 2022, 5:12 AM

Change 801350 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/libs/metrics-platform@master] [JS][PHP]: Prefix-match event names

https://gerrit.wikimedia.org/r/801350

Change 801350 merged by jenkins-bot:

[mediawiki/libs/metrics-platform@master] [JS][PHP]: Prefix-match event names

https://gerrit.wikimedia.org/r/801350

Change 804280 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/EventLogging@master] lib: Update lib/metrics-platform to f8693e71807

https://gerrit.wikimedia.org/r/804280

Change 804280 merged by jenkins-bot:

[mediawiki/extensions/EventLogging@master] lib: Update lib/metrics-platform to f8693e71807

https://gerrit.wikimedia.org/r/804280

phuedx renamed this task from Allow a stream to register interest in multiple events more easily to Allow a stream to register interest in multiple events more easily.Sep 20 2022, 3:07 PM
EChetty claimed this task.