-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add archiving metrics code with timer #23902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caddoo
wants to merge
35
commits into
5.x-dev
Choose a base branch
from
dev-19750-timing-metrics
base: 5.x-dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
69c11c5
Add archiving metrics code with timer
caddoo 27706fd
Pass in segment/period objects where possible
caddoo 96f8bc0
Make plugin not installed by default
caddoo 33d9002
Add support back in for segment archiving
caddoo d2666b9
Don't prematurely filter plugins
caddoo 994a7f2
Add additional test for when archive PHP not triggered
caddoo 47062d5
Update UI Screenshots
caddoo fb8c79a
Make archiving_metrics.idarchive not null
caddoo 975d012
Store archiving period as numeric id
caddoo f5c2896
Store segment hash in archiving metrics
caddoo a8f66b5
Derive ts_started from stored start time
caddoo e3b2716
Use mocks for Timer tests
caddoo 8cae024
Move ArchivingMetrics description to lang file
caddoo 6759035
Tighten ArchivingMetrics integration test
caddoo a95a42f
Add strict types and license headers
caddoo 713e56c
Move context field extraction into writer
caddoo c742bbf
Update screenshots
caddoo c448132
Store done flag as archive name
caddoo 8dde0bb
Add support for report timings
caddoo 099b80c
Remove null check
caddoo f87db72
Update index names
caddoo c5a6652
Add check to make sure idArchives array is always 1
caddoo b0d2ca0
Update index name
caddoo c27b944
Switch to date function
caddoo b9e061f
Remove date now() function
caddoo 8e0c2ed
Add 'type' to $runs
caddoo 9f65f9f
Add clean up task for archive metrics (#23907)
caddoo e4cdeb3
Integrate archiveReports with ArchiveMetrics timer (#23906)
caddoo 0ceb6ab
Update test to remove mocked 'now'
caddoo 0ccc6a9
Remove report from archiving metrics context
caddoo d26df02
Add report to context only
caddoo a34bf5e
Clean up test
caddoo b865b4c
Update documented parameter order
mneudert d183374
Update tests to show full year <-> day cascading behaviour
mneudert d4985cb
Update expected UI test files
mneudert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| namespace Piwik\Updates; | ||
|
|
||
| use Piwik\Updater; | ||
| use Piwik\Updater\Migration\Factory as MigrationFactory; | ||
| use Piwik\Updates as PiwikUpdates; | ||
| use Piwik\Updater\Migration; | ||
|
|
||
| /** | ||
| * Update for version 5.7.0-b1 | ||
| */ | ||
| class Updates_5_7_0_b2 extends PiwikUpdates | ||
| { | ||
| /** | ||
| * @var MigrationFactory | ||
| */ | ||
| private $migration; | ||
|
|
||
| public function __construct(MigrationFactory $factory) | ||
| { | ||
| $this->migration = $factory; | ||
| } | ||
|
|
||
| /** | ||
| * @param Updater $updater | ||
| * @return Migration[] | ||
| */ | ||
| public function getMigrations(Updater $updater) | ||
| { | ||
| return [ | ||
| $this->migration->db->createTable('archiving_metrics', [ | ||
| 'metadataid' => 'BIGINT UNSIGNED NOT NULL AUTO_INCREMENT', | ||
| 'idarchive' => 'BIGINT UNSIGNED NOT NULL', | ||
| 'idsite' => 'INTEGER UNSIGNED NOT NULL', | ||
| 'archive_name' => 'VARCHAR(255) NOT NULL', | ||
| 'date1' => 'DATE NOT NULL', | ||
| 'date2' => 'DATE NOT NULL', | ||
| 'period' => 'TINYINT UNSIGNED NOT NULL', | ||
| 'ts_started' => 'DATETIME NOT NULL', | ||
| 'ts_finished' => 'DATETIME NOT NULL', | ||
| 'total_time' => 'BIGINT UNSIGNED NOT NULL', | ||
| 'total_time_exclusive' => 'BIGINT UNSIGNED NOT NULL', | ||
| ], ['metadataid']), | ||
| $this->migration->db->addIndex('archiving_metrics', ['idarchive'], 'index_idarchive'), | ||
| $this->migration->db->addIndex('archiving_metrics', ['idsite', 'archive_name'], 'index_idsite_archive_name'), | ||
| $this->migration->db->addIndex('archiving_metrics', ['idsite', 'date1', 'period'], 'index_idsite_date1_period'), | ||
| ]; | ||
| } | ||
|
|
||
| public function doUpdate(Updater $updater) | ||
| { | ||
| $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Piwik\Plugins\ArchivingMetrics; | ||
|
|
||
| use Piwik\Period; | ||
| use Piwik\Segment; | ||
|
|
||
| class ArchivingMetrics extends \Piwik\Plugin | ||
| { | ||
| public function registerEvents() | ||
| { | ||
| return [ | ||
| 'CoreAdminHome.archiveReports.start' => 'onArchiveReportsStart', | ||
| 'CoreAdminHome.archiveReports.complete' => 'onArchiveReportsComplete', | ||
| ]; | ||
| } | ||
|
|
||
| public function onArchiveReportsStart( | ||
| int $idSite, | ||
| Period $period, | ||
| Segment $segment, | ||
| string $plugin, | ||
| $report, | ||
| bool $isArchivePhpTriggered | ||
| ): void { | ||
| $timer = Timer::getInstance($isArchivePhpTriggered); | ||
| $context = $this->buildContext($idSite, $period, $segment, $plugin, $report); | ||
|
|
||
| $timer->start($context); | ||
| } | ||
|
|
||
| /** | ||
| * @param int[] $idArchives | ||
| */ | ||
| public function onArchiveReportsComplete( | ||
| int $idSite, | ||
| Period $period, | ||
| Segment $segment, | ||
| string $plugin, | ||
| $report, | ||
| bool $isArchivePhpTriggered, | ||
| array $idArchives, | ||
| bool $wasCached | ||
| ): void { | ||
| $timer = Timer::getInstance($isArchivePhpTriggered); | ||
| $context = $this->buildContext($idSite, $period, $segment, $plugin, $report); | ||
|
|
||
| $timer->complete($context, $idArchives, $wasCached); | ||
| } | ||
|
|
||
| private function buildContext(int $idSite, Period $period, Segment $segment, string $plugin, $report): Context | ||
| { | ||
| return new Context($idSite, $period, $segment, $plugin, $report); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Piwik\Plugins\ArchivingMetrics\Clock; | ||
|
|
||
| final class Clock implements ClockInterface | ||
| { | ||
| public function microtime(): float | ||
| { | ||
| return microtime(true); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Piwik\Plugins\ArchivingMetrics\Clock; | ||
|
|
||
| interface ClockInterface | ||
| { | ||
| public function microtime(): float; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Matomo - free/libre analytics platform | ||
| * | ||
| * @link https://matomo.org | ||
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Piwik\Plugins\ArchivingMetrics; | ||
|
|
||
| use Piwik\Period; | ||
| use Piwik\Segment; | ||
|
|
||
| final class Context | ||
| { | ||
| /** | ||
| * @var int | ||
| */ | ||
| public $idSite; | ||
|
|
||
| /** | ||
| * @var Period | ||
| */ | ||
| public $period; | ||
|
|
||
| /** | ||
| * @var Segment | ||
| */ | ||
| public $segment; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| public $plugin; | ||
|
|
||
| /** | ||
| * @var false|string|string[] | ||
| */ | ||
| public $report; | ||
|
|
||
| /** | ||
| * @param false|string|string[] $report | ||
| */ | ||
| public function __construct(int $idSite, Period $period, Segment $segment, string $plugin, $report = false) | ||
| { | ||
| $this->idSite = $idSite; | ||
| $this->period = $period; | ||
| $this->segment = $segment; | ||
| $this->plugin = $plugin; | ||
| $this->report = $report; | ||
| } | ||
|
|
||
| public function getKey(): string | ||
| { | ||
| return implode('|', [ | ||
| $this->idSite, | ||
| $this->period->getLabel(), | ||
| $this->segment->getString(), | ||
| $this->period->getDateTimeStart()->toString('Y-m-d'), | ||
| $this->period->getDateTimeEnd()->toString('Y-m-d'), | ||
| $this->plugin, | ||
| ]); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.