openclerk / metrics
There is no license information available for the latest version (0.1.0) of this package.
0.1.0
2017-09-11 07:39 UTC
Requires
- openclerk/config: ^0.1
- openclerk/db: ^0.1
- openclerk/events: ^0.2
This package is auto-updated.
Last update: 2024-11-14 09:31:43 UTC
README
A library for simple metrics (page, database) capture in PHP.
Installing
Include openclerk/metrics
as a requirement in your project composer.json
,
and run composer update
to install it into your project:
{ "require": { "openclerk/metrics": "dev-master" } }
Make sure that you run all of the migrations that can be discovered through component-discovery; see the documentation on openclerk/db for more information.
$migrations = new AllMigrations(db()); if ($migrations->hasPending(db())) { $migrations->install(db(), $logger); }
Features
- Capture runtime metrics of pages and databases (through openclerk/db)
- Capture runtime metrics of templates (through openclerk/pages)
- Optionally store runtime metrics into the database (requires migrations through component-discovery)
- Optionally generate performance reports (requires openclerk/jobs)
Using
This project uses openclerk/db for database management, openclerk/events for capturing and processing events, and openclerk/config for config management.
Configure the component if necessary:
Openclerk\Config::merge(array( // these are default values "metrics_enabled" => true, "metrics_db_enabled" => true, "metrics_page_enabled" => true, "metrics_templates_enabled" => true, // store reports into the database "metrics_store" => false, ));
You now need to register the metrics events handlers, and trigger the page events as necessary:
// set up metrics Openclerk\MetricsHandler::init(db()); // trigger page load metrics Openclerk\Events::trigger('page_init', null); // when rendering a page... Openclerk\Events::trigger('page_start', null); // do things Openclerk\Events::trigger('page_end', null); // print out metrics stats print_r(Openclerk\MetricsHandler::getInstance()->printResults());
TODO
- Tests
- CURL report jobs
- How to extend your metrics capture (e.g. graphs metrics)