- PHP ^8.0
- Laravel ^8.0
- InfluxDB >= 2.0
composer require stryber/laravel-metrics
You can publish the config files with the following command:
php artisan vendor:publish --tag="stryber-mectrics"
Check examples folder for:
- env.example env file with variables you should use to configure the package - copy them to your .env
- docker-compose.yml docker-compose file with influxdb service example
- main_dashboard.json exported influxdb dashboard to import on new influxdb instance
For now package supports 1 driver - influxdb and collects 3 metrics - Command, Request and Query.
Command and Query metrics will be collected automatically after you install the package.
To make Request metrics work you have to enable middleware called 'collect-metrics'
.
Feel free to add your own metric classes to collect metrics in your project.
For this you should extend \Stryber\Metrics\Collectables\Metric
class and, if you're using influxdb, make
transformer from \Stryber\Metrics\Drivers\Influx\Transformers\MetricTransformer
or
\Stryber\Metrics\Drivers\Influx\Transformers\Transformer
based on your needs.
If so, don't forget to add your transformer's resolver to config.
If you want to fill metric's storage with some data don't use laravel test setup.
Based of current state of stryber/laravel-uuid-helper
and laravel test request realization you will have all
metrics with the same request-id.