Page MenuHomePhabricator

[CLIENT][SW][GRAFMIGR] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib
Closed, ResolvedPublic

Description

Follow the migration process as outlined below.

Secure/Conduct code review(s).
Deploy the changes to production via the train (https://wikitech.wikimedia.org/wiki/Deployments/Train).
Verify that the changes have been successfully implemented.
Update the relevant dashboard(s) by replacing the old Graphite metric(s) with the new Prometheus metric(s).
Please follow the guidelines and standards outlined in the provided documentation:

https://www.mediawiki.org/wiki/Manual:Stats for detailed guidance on the conversion process.
https://drive.google.com/file/d/12yQEuOapkML1vb9MgCaX1QzbLBdXE6X2/view for a video tutorial on the conversion process.
https://docs.google.com/presentation/d/1SZWf_D3mWNX-XHN8PHYI84LDZr6GUQC2AMhZ9mQXCI0/edit#slide=id.g2795460c956_0_23 for slides on the best practices for converting metrics to statslib.

  • MediaWiki.$prefix.wikibase.client.scribunto.entity.*.call.rate
  • MediaWiki.$prefix.wikibase.client.scribunto.wikibase.*.call.rate
  • MediaWiki.$prefix.wikibase.client.scribunto.wikibase.getEntityStatements.cache_miss.rate
  • MediaWiki.$prefix.wikibase.client.scribunto.wikibase.getEntityStatements.call.rate

source code
usage (incrementStatsKey)

Event Timeline

Lucas_Werkmeister_WMDE renamed this task from Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib to [CLIENT][SW] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib.Apr 25 2024, 12:37 PM

TBH, I think I’d like to start the statslib migration in Wikibase with another task than this… this task carries the additional complication that the tracking happens from Lua (mw.wikibase.lua and mw.wikibase.entity.lua call incrementStatsdKey() with hard-coded, but [as far as PHP is concerned] arbitrary string metric keys), and I think it would be less confusing for us to learn statslib on an easier conversion first. @Arian_Bozorg is it okay if we put one of the other Wikibase subtasks of T350592 ahead of this one? (E.g. T359251, though that one is probably big enough that it could be broken down into several subtasks. T359248 is probably an even better candidate.)


In the meantime, question for the statslib experts here: how “bad” would it be if we implemented the PHP code like this, still leaving the Lua code with the ability to decide which names to use?

$statsFactory->getCounter( $oneStringFromLua )
	// maybe ->setLabel()
	->copyToStatsdAt( $anotherStringFromLua )
	->increment();

This would potentially result in several calls to ->getCounter() with the same name. Is that a problem, or can the stats factory handle the deduplication (if necessary)? (I assume this isn’t the most idiomatic way to use statslib, but it would at least be a relatively straightforward conversion, I hope.)

(Note: “Lua code” is just Wikibase’s own Lua code, not on-wiki modules – we don’t give those access to our internal interface, don’t worry ^^)

In the meantime, question for the statslib experts here: how “bad” would it be if we implemented the PHP code like this, still leaving the Lua code with the ability to decide which names to use?

$statsFactory->getCounter( $oneStringFromLua )
	// maybe ->setLabel()
	->copyToStatsdAt( $anotherStringFromLua )
	->increment();

If you want to have Lua keep control of the metrics, that's probably the only way. The main recommendation it breaks is to avoid using variables in metric names. The reason for this guidance is so that the source of any given metric are more easily found in codesearch.

This would potentially result in several calls to ->getCounter() with the same name. Is that a problem, or can the stats factory handle the deduplication (if necessary)? (I assume this isn’t the most idiomatic way to use statslib, but it would at least be a relatively straightforward conversion, I hope.)

Each call to getCounter() results in a hash lookup. Given the same metric name, you'll get a previously-created instance back if one exists. Calls to setLabel() must be identical between uses as well.

karapayneWMDE renamed this task from [CLIENT][SW] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib to [CLIENT][SW][GRAFMIGR] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib.Aug 29 2024, 8:12 AM

Change #1131115 had a related patch set uploaded (by Andrea Denisse; author: Andrea Denisse):

[mediawiki/extensions/Wikibase@master] wikibase: Migrate MediaWiki.Site*.scribunto.*.call.rate to Prometheus

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

Change #1131731 had a related patch set uploaded (by Hasan Akgün (WMDE); author: Hasan Akgün (WMDE)):

[mediawiki/extensions/Wikibase@master] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib

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

Change #1131115 abandoned by Andrea Denisse:

[mediawiki/extensions/Wikibase@master] wikibase: Migrate MediaWiki.Site*.scribunto.*.call.rate to Prometheus

Reason:

Abandoning in favor of 1131731

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

Change #1131731 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib

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

Change #1139427 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Hasan Akgün (WMDE)):

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.25] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib

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

Change #1139427 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@wmf/1.44.0-wmf.25] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib

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

Mentioned in SAL (#wikimedia-operations) [2025-04-28T13:19:55Z] <lucaswerkmeister-wmde@deploy1003> Started scap sync-world: Backport for [[gerrit:1139426|Migrate MediaWiki.wikibase.* stats (T359251 T359252)]], [[gerrit:1139427|Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib (T359253)]]

Mentioned in SAL (#wikimedia-operations) [2025-04-28T13:24:18Z] <lucaswerkmeister-wmde@deploy1003> lucaswerkmeister-wmde: Backport for [[gerrit:1139426|Migrate MediaWiki.wikibase.* stats (T359251 T359252)]], [[gerrit:1139427|Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib (T359253)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2025-04-28T13:33:48Z] <lucaswerkmeister-wmde@deploy1003> Finished scap sync-world: Backport for [[gerrit:1139426|Migrate MediaWiki.wikibase.* stats (T359251 T359252)]], [[gerrit:1139427|Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib (T359253)]] (duration: 13m 52s)