Download the PHP package middleware/agent-apm-php without Composer
On this page you can find all versions of the php package middleware/agent-apm-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download middleware/agent-apm-php
More information about middleware/agent-apm-php
Files in middleware/agent-apm-php
Informations about the package agent-apm-php
Getting Started
agent-apm-php
Description: Agent APM for PHP
Prerequisites
- To monitor APM data on dashboard, Middleware Host-agent needs to be installed, You can refer this demo project to refer use cases of APM.
- PHP requires at least PHP 8+ and OpenTelemetry PHP-Extension to run this agent.
Guides
To use this APM agent, follow below steps:
- Run
composer require middleware/agent-apm-phpin your project directory. - After successful installation, you need to add
require 'vendor/autoload.php';in your file. - Then after, you need to add
use Middleware\AgentApmPhp\MwTracker;line. -
Now, add following code to the next line with your Project & Service name:
-
Then we have 2 functions, named
preTrack()&postTrack(), your code must be placed between these functions. After preTrack() calls, you need to register your desired classes & functions as follows: -
You can add your own custom attributes as the third parameter, and checkout many other pre-defined attributes here.
-
At the end, just call
postTrack()function, which will send all the traces to the Middleware Host-agent. -
If you want to enable Logging feature along with tracing in your project, then you can use below code snippet:
- So, final code snippet will look like as:
Note: OTEL collector endpoint for all the traces, will be http://localhost:9320/v1/traces by default.
Sample Code
All versions of agent-apm-php with dependencies
open-telemetry/sdk Version ^1.0
symfony/http-client Version ^6.3
guzzlehttp/promises Version ^2.0
php-http/message-factory Version ^1.1
nyholm/psr7 Version ^1.8
open-telemetry/api Version ^1.0
open-telemetry/exporter-otlp Version ^1.0
open-telemetry/opentelemetry-auto-psr15 Version ^1.0
psr/http-client Version ^1.0
google/protobuf Version ^3.25
php-http/httplug Version ^2.4