nivseb / lara-monitor
APM agent for laravel projects to monitor the application with elastic apm tools.
Requires
- php: ^8.1
- composer-runtime-api: ^2.0
- ext-posix: *
- illuminate/contracts: ^10.0|^11.0
- jasny/persist-sql-query: v3.0.0-alpha1
Requires (Dev)
- ext-pdo: *
- ext-redis: *
- friendsofphp/php-cs-fixer: ^3.64
- guzzlehttp/guzzle: ^7.8
- kubawerlos/php-cs-fixer-custom-fixers: ^3.22
- laravel/octane: ^1.0|^2.0
- mockery/mockery: ^1.6
- nunomaduro/phpinsights: ^2.12
- orchestra/pest-plugin-testbench: ^2.0
- orchestra/testbench: ^8.28|^9.0
- pestphp/pest: ^2.36
- pestphp/pest-plugin-faker: ^2.0
- phpstan/phpstan: ^1.12
- rector/rector: ^1.2
- dev-main
- v0.8.0
- dev-add-authorization-via-secret-token
- dev-release-please--branches--main
- dev-extend-documentation
- dev-remove-php-8.1
- dev-no-traceparent-header-for-finished-trace-event
- dev-prevent-collecting-after-trace-parent-is-completed
- dev-correct-http-middleware-trace-parent-config
- dev-add-test-for-trace-parent-middleware
- dev-drop-service-node-name
- dev-add-support-for-laravel-12
- dev-lara-monitor-30
This package is auto-updated.
Last update: 2025-05-22 21:09:29 UTC
README
Lara-Monitor is apm agent package for application that are build with Laravel Framework. The collected data are send to your Elastic APM Server. That allow you an impressive look to your application via kibana. This package make it easy to connect all needed information from your application in Elastic Kibana. This package was developed primarily for container-based environments that use Laravel Octane. But it works fine in over environments like plain laravel application as docker container or hostet plain on servers.
Lara-Monitor collect information directly from laravel events and callbacks. That allows a very easy integration, but Lara-Monitor is also designed to be especially customizable, so that you can build that monitoring that is the best for your application.
Feature
Read more about the collecting process:
- Recording Transactions from request, commands and jobs
- Collect information about exceptions and errors
- Collect database queries from your application
- Collect http request information against a third-party system
- Collect redis commands from your application
- Collect information from your rendering processes
- Extend Logging
At the moment the only agent that is supported, sends the collected data to the Elastic APM Server. In the feature it would be extended with other agents, or you can build your ownagent. Read more about the elastic agent.
Octane Support
The request handling in application that use Laravel Octane, is a little different to normal laravel request handling. This makes it necessary to collect data for the apm on another way, to get a good look at the performance monitoring.
Only the task worker are not supported. Everything that is done in a task worker will not see in the collected data.
Customizability
All parts are only connected via interfaces, that allows you easily to customize the agent for your requirements. Overwrite the part of the agent, that need to be changed and register your variant. If you think that this also help others, create a pull request and make it possible for everyone to get advantage of it.
Installation
-
To install PHP Mock Server Connector you can easily use composer.
composer require nivseb/lara-monitor
-
Add
Nivseb\LaraMonitor\Providers\LaraMonitorStartServiceProvider
to your application -
Add
Nivseb\LaraMonitor\Providers\LaraMonitorEndServiceProvider
to your application -
Publish and change config or add needed environment variables
The provider should be added manuale to the loaded service provider. This allows you to get the best information from
the tracking. The LaraMonitorStartServiceProvider
Should be loaded as early as possible and the
LaraMonitorEndServiceProvider
should be loaded as late as possible. That include as much as possible other event listeners to monitored for the spans.
Configuration
Lara-Monitor comes with an own config, you can publish it with the following command.
php artisan vendor:publish --tag=lara-monitor-config
The most configs are set by default laravel environment variables (e.g. APP_NAME
or APP_ENV
).
For a full documentation see the Configuration.