inspector-apm / inspector-php
Inspector for PHP applications.
Installs: 1 327 329
Dependents: 7
Suggesters: 0
Security: 0
Stars: 26
Watchers: 2
Forks: 8
Open Issues: 1
Requires
- php: >=7.2
Requires (Dev)
- phpunit/phpunit: ^9.0
- dev-master
- 3.8.7
- 3.8.6
- 3.8.5
- 3.8.4
- 3.8.3
- 3.8.2
- 3.8.1
- 3.8.0
- 3.7.28
- 3.7.27
- 3.7.26
- 3.7.25
- 3.7.24
- 3.7.23
- 3.7.22
- 3.7.21
- 3.7.20
- 3.7.19
- 3.7.18
- 3.7.17
- 3.7.16
- 3.7.15
- 3.7.14
- 3.7.13
- 3.7.12
- 3.7.11
- 3.7.10
- 3.7.9
- 3.7.8
- 3.7.7
- 3.7.6
- 3.7.4
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.17
- 3.5.16
- 3.5.15
- 3.5.14
- 3.5.13
- 3.5.12
- 3.5.11
- 3.5.10
- 3.5.9
- 3.5.8
- 3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.18
- 3.2.17
- 3.2.16
- 3.2.15
- 3.2.14
- 3.2.13
- 3.2.12
- 3.2.11
- 3.2.10
- 3.2.9
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.4.8
- 2.4.7
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.12
- 2.3.11
- 2.3.10
- 2.3.9
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.2.1
- 2.2.0
- 2.1.14
- 2.1.13
- 2.1.12
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.14
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-develop
This package is auto-updated.
Last update: 2024-11-07 09:30:23 UTC
README
Before moving on, please consider giving us a GitHub star ⭐️. Thank you!
Code Execution Monitoring, built for PHP developers.
Requirements
- PHP >= 7.2.0
Install
Install the latest version by:
composer require inspector-apm/inspector-php
Use
To start sending data to Inspector you need an Ingestion Key to create an instance of the Configuration
class.
You can obtain INSPECTOR_API_KEY
creating a new project in your Inspector dashboard.
use Inspector\Inspector; use Inspector\Configuration; $configuration = new Configuration('YOUR_INGESTION_KEY'); $inspector = new Inspector($configuration);
All start with a transaction
. Transaction represent an execution cycle and it can contains one or hundred of segments:
// Start an execution cycle with a transaction $inspector->startTransaction($_SERVER['PATH_INFO']);
Use addSegment
method to monitor a code block in your transaction:
$result = $inspector->addSegment(function ($segment) { // Do something here... return "Hello World!"; }, 'my-process'); echo $result; // this will print "Hello World!"
Inspector will monitor your code execution in real time alerting you if something goes wrong.
Custom Transport
You can also set up custom transport class to transfer monitoring data from your server to Inspector in a personalized way.
The transport class needs to implement \Inspector\Transports\TransportInterface
:
class CustomTransport implements \Inspector\Transports\TransportInterface { protected $configuration; protected $queue = []; public function __constructor($configuration) { $this->configuration = $configuration; } public function addEntry(\Inspector\Models\Arrayable $entry) { // Add an \Inspector\Models\Arrayable entry in the queue. $this->queue[] = $entry; } public function flush() { // Performs data transfer. $handle = curl_init('https://ingest.inspector.dev'); curl_setopt($handle, CURLOPT_POST, 1); curl_setopt($handle, CURLOPT_HTTPHEADER, [ 'X-Inspector-Key: xxxxxxxxxxxx', 'Content-Type: application/json', 'Accept: application/json', ]); curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($this->queue)); curl_exec($handle); curl_close($handle); } }
Then you can set the new transport in the Inspector
instance
using a callback the will receive the current configuration state as parameter.
$inspector->setTransport(function ($configuration) { return new CustomTransport($configuration); });
Chek out the official documentation
Contributing
We encourage you to contribute to Inspector! Please check out the Contribution Guidelines about how to proceed. Join us!
LICENSE
This package is licensed under the MIT license.