Skip to content
Extraits de code Groupes Projets
Valider 2344a38f rédigé par mattab's avatar mattab
Parcourir les fichiers

Better logging messages for core:archive output

 * made output more consistent and easier to read by a human
 * better summary report for "Skipped websites" stats
parent ee05506b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -208,7 +208,10 @@ class CronArchive ...@@ -208,7 +208,10 @@ class CronArchive
private $websitesWithVisitsSinceLastRun = 0; private $websitesWithVisitsSinceLastRun = 0;
private $skippedPeriodsArchivesWebsite = 0; private $skippedPeriodsArchivesWebsite = 0;
private $skippedPeriodsNoDataInPeriod = 0;
private $skippedDayArchivesWebsites = 0; private $skippedDayArchivesWebsites = 0;
private $skippedDayNoRecentData = 0;
private $skippedDayOnApiError = 0;
private $skipped = 0; private $skipped = 0;
private $processed = 0; private $processed = 0;
private $archivedPeriodsArchivesWebsite = 0; private $archivedPeriodsArchivesWebsite = 0;
...@@ -366,17 +369,23 @@ class CronArchive ...@@ -366,17 +369,23 @@ class CronArchive
// to process the archives for this website (only if there were visits since midnight) // to process the archives for this website (only if there were visits since midnight)
if (!$hasWebsiteDayFinishedSinceLastRun && !$isOldReportInvalidatedForWebsite) { if (!$hasWebsiteDayFinishedSinceLastRun && !$isOldReportInvalidatedForWebsite) {
if ($this->isWebsiteUsingTheTracker($idSite) && if ($this->isWebsiteUsingTheTracker($idSite)) {
!$this->hadWebsiteTrafficSinceMidnightInTimezone($idSite)) {
$this->logger->info("Will skip website $idSite as archiving is not needed"); if(!$this->hadWebsiteTrafficSinceMidnightInTimezone($idSite)) {
$this->skipped++; $this->logger->info("Skipped website id $idSite as archiving is not needed");
continue;
$this->skippedDayNoRecentData++;
$this->skipped++;
continue;
}
} else {
$this->logger->info("- website id $idSite is not using the tracker");
} }
} elseif ($hasWebsiteDayFinishedSinceLastRun) { } elseif ($hasWebsiteDayFinishedSinceLastRun) {
$this->logger->info("Day has finished for website $idSite since last run"); $this->logger->info("Day has finished for website id $idSite since last run");
} elseif ($isOldReportInvalidatedForWebsite) { } elseif ($isOldReportInvalidatedForWebsite) {
$this->logger->info("Old report was invalidated for website $idSite"); $this->logger->info("Old report was invalidated for website id $idSite");
} }
} }
...@@ -408,9 +417,18 @@ class CronArchive ...@@ -408,9 +417,18 @@ class CronArchive
$this->skipped = $totalWebsites - $this->websitesWithVisitsSinceLastRun; $this->skipped = $totalWebsites - $this->websitesWithVisitsSinceLastRun;
$this->logger->info("Archived today's reports for {$this->websitesWithVisitsSinceLastRun} websites"); $this->logger->info("Archived today's reports for {$this->websitesWithVisitsSinceLastRun} websites");
$this->logger->info("Archived week/month/year for {$this->archivedPeriodsArchivesWebsite} websites"); $this->logger->info("Archived week/month/year for {$this->archivedPeriodsArchivesWebsite} websites");
$this->logger->info("Skipped {$this->skipped} websites: no new visit since the last script execution"); $this->logger->info("Skipped {$this->skipped} websites");
$this->logger->info("Skipped {$this->skippedDayArchivesWebsites} websites day archiving: existing daily reports are less than {$this->todayArchiveTimeToLive} seconds old"); $this->logger->info("- Skipped {$this->skippedDayNoRecentData} websites: no new visit since the last script execution");
$this->logger->info("Skipped {$this->skippedPeriodsArchivesWebsite} websites week/month/year archiving: existing periods reports are less than {$this->processPeriodsMaximumEverySeconds} seconds old"); $this->logger->info("- Skipped {$this->skippedDayArchivesWebsites} websites day archiving: existing daily reports are less than {$this->todayArchiveTimeToLive} seconds old");
$this->logger->info("- Skipped {$this->skippedPeriodsArchivesWebsite} websites week/month/year archiving: existing periods reports are less than {$this->processPeriodsMaximumEverySeconds} seconds old");
if($this->skippedPeriodsNoDataInPeriod) {
$this->logger->info("- Skipped {$this->skippedPeriodsNoDataInPeriod} websites week/month/year archiving: no visit in recent days");
}
if($this->skippedDayOnApiError) {
$this->logger->info("- Skipped {$this->skippedDayOnApiError} websites: got an error while querying reporting API");
}
$this->logger->info("Total API requests: {$this->requests}"); $this->logger->info("Total API requests: {$this->requests}");
//DONE: done/total, visits, wtoday, wperiods, reqs, time, errors[count]: first eg. //DONE: done/total, visits, wtoday, wperiods, reqs, time, errors[count]: first eg.
...@@ -589,6 +607,9 @@ class CronArchive ...@@ -589,6 +607,9 @@ class CronArchive
return false; return false;
} }
/**
* Trigger archiving for days
*/
try { try {
$shouldProceed = $this->processArchiveDays($idSite, $lastTimestampWebsiteProcessedDay, $shouldArchivePeriods, $timerWebsite); $shouldProceed = $this->processArchiveDays($idSite, $lastTimestampWebsiteProcessedDay, $shouldArchivePeriods, $timerWebsite);
} catch (UnexpectedWebsiteFoundException $e) { } catch (UnexpectedWebsiteFoundException $e) {
...@@ -605,11 +626,14 @@ class CronArchive ...@@ -605,11 +626,14 @@ class CronArchive
$this->logger->info("Skipped website id $idSite periods processing, already done " $this->logger->info("Skipped website id $idSite periods processing, already done "
. $this->formatter->getPrettyTimeFromSeconds($elapsedSinceLastArchiving, true) . $this->formatter->getPrettyTimeFromSeconds($elapsedSinceLastArchiving, true)
. " ago, " . $timerWebsite->__toString()); . " ago, " . $timerWebsite->__toString());
$this->skippedDayArchivesWebsites++; $this->skippedPeriodsArchivesWebsite++;
$this->skipped++; $this->skipped++;
return false; return false;
} }
/**
* Trigger archiving for non-day periods
*/
$success = $this->processArchiveForPeriods($idSite, $lastTimestampWebsiteProcessedPeriods); $success = $this->processArchiveForPeriods($idSite, $lastTimestampWebsiteProcessedPeriods);
// Record succesful run of this website's periods archiving // Record succesful run of this website's periods archiving
...@@ -761,6 +785,7 @@ class CronArchive ...@@ -761,6 +785,7 @@ class CronArchive
} }
$this->logError("Empty or invalid response '$content' for website id $idSite, " . $timerWebsite->__toString() . ", skipping"); $this->logError("Empty or invalid response '$content' for website id $idSite, " . $timerWebsite->__toString() . ", skipping");
$this->skippedDayOnApiError++;
$this->skipped++; $this->skipped++;
return false; return false;
} }
...@@ -777,6 +802,7 @@ class CronArchive ...@@ -777,6 +802,7 @@ class CronArchive
&& !$shouldArchivePeriods && !$shouldArchivePeriods
) { ) {
$this->logger->info("Skipped website id $idSite, no visit today, " . $timerWebsite->__toString()); $this->logger->info("Skipped website id $idSite, no visit today, " . $timerWebsite->__toString());
$this->skippedDayNoRecentData++;
$this->skipped++; $this->skipped++;
return false; return false;
} }
...@@ -787,6 +813,7 @@ class CronArchive ...@@ -787,6 +813,7 @@ class CronArchive
) { ) {
$humanReadableDate = $this->formatReadableDateRange($date); $humanReadableDate = $this->formatReadableDateRange($date);
$this->logger->info("Skipped website id $idSite, no visits in the $humanReadableDate days, " . $timerWebsite->__toString()); $this->logger->info("Skipped website id $idSite, no visits in the $humanReadableDate days, " . $timerWebsite->__toString());
$this->skippedPeriodsNoDataInPeriod++;
$this->skipped++; $this->skipped++;
return false; return false;
} }
...@@ -1132,9 +1159,9 @@ class CronArchive ...@@ -1132,9 +1159,9 @@ class CronArchive
$hasVisits = $dao->hasSiteVisitsBetweenTimeframe($from, $to, $idSite); $hasVisits = $dao->hasSiteVisitsBetweenTimeframe($from, $to, $idSite);
if ($hasVisits) { if ($hasVisits) {
$this->logger->info("$idSite has visits between $from and $to"); $this->logger->info("- tracking data found for website id $idSite (between $from and $to)");
} else { } else {
$this->logger->info("$idSite has no visits between $from and $to"); $this->logger->info("- no new tracking data for website id $idSite (between $from and $to)");
} }
return $hasVisits; return $hasVisits;
...@@ -1406,16 +1433,12 @@ class CronArchive ...@@ -1406,16 +1433,12 @@ class CronArchive
Piwik::postEvent('CronArchive.getIdSitesNotUsingTracker', array(&$this->idSitesNotUsingTracker)); Piwik::postEvent('CronArchive.getIdSitesNotUsingTracker', array(&$this->idSitesNotUsingTracker));
if (!empty($this->idSitesNotUsingTracker)) { if (!empty($this->idSitesNotUsingTracker)) {
$this->logger->info("The following websites do not use the tracker: " . implode(',', $this->idSitesNotUsingTracker)); $this->logger->info("- The following websites do not use the tracker: " . implode(',', $this->idSitesNotUsingTracker));
} }
} }
$isUsingTracker = !in_array($idSite, $this->idSitesNotUsingTracker); $isUsingTracker = !in_array($idSite, $this->idSitesNotUsingTracker);
if (!$isUsingTracker) {
$this->logger->info("The website $idSite is not using the tracker");
}
return $isUsingTracker; return $isUsingTracker;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter