cognesy / instructor-metrics
Event-driven metrics collection system for Instructor PHP library
v2.1.0
2026-03-16 19:27 UTC
Requires
- php: ^8.3
- cognesy/instructor-events: ^2.1
- psr/event-dispatcher: ^1.0
- psr/log: ^3.0
Requires (Dev)
- icanhazstring/composer-unused: ^0.9.0
- jetbrains/phpstorm-attributes: ^1.2
- maglnet/composer-require-checker: ^4.16
- pestphp/pest: ^2.34
- phpstan/phpstan: ^1.11
- roave/security-advisories: dev-latest
- vimeo/psalm: ^6.0
README
Event-driven metrics collection for InstructorPHP.
Use it to:
- collect metrics from event listeners
- store them in a registry
- export them to logs or custom backends
Example
<?php use Cognesy\Events\Dispatchers\EventDispatcher; use Cognesy\Metrics\Data\Tags; use Cognesy\Metrics\Exporters\CallbackExporter; use Cognesy\Metrics\Metrics; $metrics = (new Metrics(new EventDispatcher())) ->exportTo(new CallbackExporter(function (iterable $items): void { foreach ($items as $metric) { // send metric to your backend } })); $metrics->registry()->counter('requests_total', Tags::of(['route' => '/health'])); $metrics->export();
Documentation
packages/metrics/CHEATSHEET.mdpackages/metrics/src/