wizaplace / elastic-apm-wrapper
Wizaplace Elastic APM Wrapper
Installs: 3 980
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 13
Forks: 0
Open Issues: 0
Requires
- monolog/monolog: ~1.0 || ~2.0
- wizaplace/elastic-apm-php-agent: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- infection/infection: ^0.15.3
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.25
- phpstan/phpstan-deprecation-rules: ^0.12.4
- phpstan/phpstan-strict-rules: ^0.12.2
- phpunit/phpunit: ^7
- squizlabs/php_codesniffer: ^3.5
README
Elastic APM Wrapper
PHP Wrapper to send Logs to Elastic APM
Installation
The recommended way to install the wrapper is through Composer.
Run the following composer command:
composer require wizaplace/elastic-apm-wrapper
Configuration
Communication with Elastic APM is managed by elastic-apm-php-agent (\PhilKra\Agent).
In order to instantiate the service using this agent, you have to provide several parameters :
appName
(e.g. 'Wizaplace')appVersion
(e.g. '1.0.0')environment
(e.g. 'Development', 'Production')serverUrl
APM Server EndpointsecretToken
Secret token for your Elastic APM Servertimeout
Guzzle Client timeout
Usage
Transaction
Transactions are the highest level of work you’re measuring within a service, like a request to your server. The main idea is that you monitor one transaction at a time: your PHP script being executed.
To start a transaction, you need to use the startTransaction()
method within AgentService.php.
It should be stopped (using stopTransaction()
) at the very end of the application you're monitoring.
Ideally, you wil start the transaction at the beginning of each entry point of your application
and stop it at the end of each.
Spans
Spans can be seen as 'sub-transactions', meaning they are used to help to watch parts of your application.
A new span can be started as one or several spans are already started. It is important to stop manually all the spans you started otherwise they will be closed automatically meaning you won't really get accurate data.
Within one transaction there can be 0-* spans captured.
Apm Handler
A custom Monolog handler (ApmHandler.php
) has been included to this package, enabling you to send data to the APM automatically when Monolog is called.
This configuration is optional.
Licence
This library is distributed under the terms of the MIT licence.