[go: nahoru, domu]

Page MenuHomePhabricator

[CLIENT][SW][GRAFMIGR] Migrate MediaWiki.$prefix.wikibase.client.scribunto.* to statslib
Open, Needs TriagePublic

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.Thu, Aug 29, 8:12 AM