Page MenuHomePhabricator

Create a maintenance script to publish to statsd metrics about the mediamoderation_scan table
Closed, ResolvedPublic2 Estimated Story Points

Description

To achieve T351421: Create a Grafana chart to plot the number of checked and unchecked images per wiki, a maintenance script that publishes to statsd various metrics about the number of unscanned and scanned images is needed.

Acceptance criteria
  • Have a maintenance script that publishes these stats to statsd
  • Make sure this maintenance script is well tested

Event Timeline

Change 981634 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/MediaModeration@master] Add updateMetrics.php maintenance script along with statds support

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

Change 981634 merged by jenkins-bot:

[mediawiki/extensions/MediaModeration@master] Add updateMetrics.php maintenance script along with statsd support

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

Change 982492 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/MediaModeration@master] Add ScannedImagesMetric to MetricsFactory::METRICS

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

Change 982492 merged by jenkins-bot:

[mediawiki/extensions/MediaModeration@master] Add ScannedImagesMetric to MetricsFactory::METRICS

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

This ticket can be partly QA'd, though some of the behaviour added (sending data to statsd) is difficult to effectively QA at this stage. This part should be able to be QA'd in T351421: Create a Grafana chart to plot the number of checked and unchecked images per wiki which is dependent on the code written here.

To test the rest of this change you can do the following (on betawikis or local environment):

  1. Open up the console (on beta just ssh but don't open up the DB)
  2. Run the updateMetrics.php maintenance script (on beta this can be done by mwscript MediaModeration:updateMetrics.php --wiki enwiki --verbose)
  3. Verify that the output of the script looks something like the following, where X is a positive integer.
MediaModeration.ScanTable.TotalCount is X.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is X.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.
  1. Open the DB for the wiki (on betawikis use sql enwiki)
  2. Run the following SQL and verify the result is the integer for X:
SELECT COUNT(*) FROM mediamoderation_scan;
  1. Run the following SQL and verify the result is the integer for X:
SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
Dreamy_Jazz set the point value for this task to 2.Dec 13 2023, 10:17 PM
Djackson-ctr subscribed.

Per the QA Steps, I was able to verify the number of scanned and unscanned images for the Media Moderation_Scan table.
@Dreamy_Jazz great work once again!!! Appreciate the detailed QA Steps, Thank you sir.

$ mwscript MediaModeration:updateMetrics.php --wiki enwiki --verbose
MediaModeration.ScanTable.TotalCount is 138.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 138.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(enwiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|      138 |
+----------+

wikiadmin@172.16.4.172(enwiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|      138 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki viwiki --verbose
MediaModeration.ScanTable.TotalCount is 3.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 3.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(viwiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|        3 |
+----------+

wikiadmin@172.16.4.172(viwiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|        3 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki commonswiki --verbose
MediaModeration.ScanTable.TotalCount is 49835.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 49835.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(commonswiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|    49835 |
+----------+

wikiadmin@172.16.4.172(commonswiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|    49835 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki fawiki --verbose
MediaModeration.ScanTable.TotalCount is 4.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 4.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(fawiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|        4 |
+----------+

wikiadmin@172.16.4.172(fawiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|        4 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki dewiki --verbose
MediaModeration.ScanTable.TotalCount is 104.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 104.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(dewiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|      104 |
+----------+

wikiadmin@172.16.4.172(dewiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|      104 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki zhwiki --verbose
MediaModeration.ScanTable.TotalCount is 12.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 12.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(zhwiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|       12 |
+----------+

wikiadmin@172.16.4.172(zhwiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|       12 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki metawiki --verbose
MediaModeration.ScanTable.TotalCount is 1.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 1.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(metawiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+

wikiadmin@172.16.4.172(metawiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|        1 |
+----------+
__________________________________________________________________________________________________

$ mwscript MediaModeration:updateMetrics.php --wiki testwiki --verbose
MediaModeration.ScanTable.TotalCount is 15.
MediaModeration.ScanTable.Scanned is 0.
MediaModeration.ScanTable.Unscanned is 15.
MediaModeration.ScanTable.UnscannedWithLastCheckedDefined is 0.

wikiadmin@172.16.4.172(testwiki)> SELECT COUNT(*) FROM mediamoderation_scan;
+----------+
| COUNT(*) |
+----------+
|       15 |
+----------+

wikiadmin@172.16.4.172(testwiki)> SELECT COUNT(*) FROM mediamoderation_scan WHERE mms_is_match IS NULL;
+----------+
| COUNT(*) |
+----------+
|       15 |
+----------+

Thanks. Resolving this ticket.