wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

As a support team member, I want to know the last time each RUCSS-related CRON job started and ended so that I know if CRON are running as exepcted

Open MathieuLamiot opened this issue 1 year ago • 3 comments

Context

As part of building a RUCSS Debug tool, some information must be stored while in WP Rocket Debug mode so that it can be monitored easily by the support team. More details here: https://www.notion.so/wpmedia/RUCSS-Issues-7adc4ed750fd4dc7902bb6881ed1204b?pvs=4#38398060400d4fcf97f27aa563483d68

Expected behavior When in debug mode (WP_ROCKET_DEBUG?), a timestamp must be updated in the DB every time:

  • the CRON process_on_submit_jobs starts
  • the CRON process_on_submit_jobs ends successfully
  • the CRON process_pending_jobs starts
  • the CRON process_pending_jobs ends successfully Those 4 timestamps must be stored in the DB and updated at every new related event.

When debug mode is off, nothing special happens. If the timestamps are in DB, they can stay there.

MathieuLamiot avatar Jan 11 '24 15:01 MathieuLamiot

Scope a solution ✅

In inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php

  • In process_pending_jobs(), add action rocket_rucss_process_pending_jobs_start at the start of the method, and rocket_rucss_process_pending_jobs_end at the end of the method
  • In process_on_submit_jobs(), add action rocket_rucss_process_on_submit_jobs_start at the start of the method, and rocket_rucss_process_on_submit_jobs_end at the end of the method

In inc/Engine/Debug/RUCSS

  • Add callbacks to the newly created actions, to store the timestamp for each into the debug option (based on 6372)

Estimate the effort ✅

Effort [S]

@MathieuLamiot A note in this case, there is already some existing logging for those

remyperona avatar Jan 15 '24 20:01 remyperona

Looks good to me.

jeawhanlee avatar Jan 22 '24 16:01 jeawhanlee

Pending for this PR to be merged before being able to test: https://github.com/wp-media/wp-rocket/pull/6411

MathieuLamiot avatar Feb 13 '24 11:02 MathieuLamiot