philkra/elastic-apm-php-agent
PHP agent for Elastic APM that instruments your application to capture transactions, spans, errors, and performance metrics. Sends telemetry to Elastic APM Server for tracing and monitoring, with support for web and CLI workloads and configurable sampling.
Kernel.php, middleware, or service providers).HandleExceptions or custom middleware.AppServiceProvider with config (e.g., config/apm.php).App\Exceptions\Handler to capture unhandled errors.Span::start()) around:
user_id, request_id) via middleware or context managers.Request handling or exception hierarchy may break auto-detection.monolog, guzzle).user_data) doesn’t expose PII without sanitization.elastic/apm-agent-php) that are actively maintained?HttpClient, Database) with custom spans.App\Exceptions\Handler.user_id, environment) via middleware.composer require php:^8.1 with --ignore-platform-reqs if needed.match expressions).Illuminate\Foundation\Bootstrap\HandleExceptions to capture exceptions early.tap() or decorators for Eloquent/Query Builder instrumentation.apm-server.yml to match Laravel’s service names (e.g., service.name: "laravel-app").transaction_sample_rate to avoid overwhelming the server.| Step | Action | Dependencies |
|---|---|---|
| 1. Setup | Install package, configure apm-server URL, and basic service metadata. |
Elastic APM Server running. |
| 2. Auto-Transactions | Add middleware to wrap requests in transactions. | Laravel middleware pipeline. |
| 3. Custom Spans | Instrument DB/API calls with spans. | Guzzle/HTTP Client, Eloquent, Queues. |
| 4. Error Reporting | Extend Handler to send exceptions to APM. |
Exception handling layer. |
| 5. Metadata | Inject dynamic labels (e.g., user_id) via middleware. |
Auth system (e.g., Laravel Sanctum). |
| 6. Validation | Verify traces in Kibana; check for missing spans/errors. | Elastic APM UI access. |
| 7. Optimization | Adjust sampling rates; prune unnecessary spans. | Performance baselines. |
How can I help you explore Laravel packages today?