- Does philkra/elastic-apm-php-agent support Laravel 10 and PHP 8.1+?
- The package was last updated in 2019 and lacks explicit support for Laravel 10 or PHP 8.x. You may encounter compatibility issues with named arguments, union types, or Laravel’s updated exception hierarchy. Test thoroughly in a staging environment before production use, or consider a maintained alternative like OpenTelemetry.
- How do I integrate this agent into Laravel’s middleware stack?
- Wrap your requests in transactions using Laravel middleware. For example, create a middleware that starts a transaction in `handle()` and stops it in `terminate()`. Alternatively, use `AppServiceProvider` to boot the agent during application startup, ensuring it captures all incoming requests via the Laravel Kernel.
- Can I trace Laravel queues (Horizon, Redis) with this package?
- There’s no built-in support for Laravel queues, so you’ll need to manually instrument queue jobs using `Span::start()` around job execution logic. For Horizon, wrap the `handle()` method of your jobs or use a queue worker event listener to start/stop spans dynamically.
- What’s the performance overhead of this APM agent in production?
- The package is designed for minimal overhead, but real-world impact depends on your sampling rate and transaction volume. Benchmark in staging with your expected request load (e.g., 10K+ RPS). If latency spikes exceed 1–2ms, adjust sampling or consider lighter alternatives like Laravel’s built-in logging.
- How do I handle sensitive data (e.g., tokens, PII) in Elastic APM?
- The agent doesn’t natively redact sensitive metadata, so manually sanitize data before sending. Use Elastic APM’s `user_data` field carefully and avoid logging raw tokens or passwords. For automated redaction, explore Elastic’s field masking or pre-process data in middleware before instrumentation.
- Are there alternatives to this package for Laravel APM?
- Yes. For active maintenance, consider **elastic/apm-agent-php** (official Elastic APM PHP agent) or **OpenTelemetry PHP**, which supports Laravel natively and integrates with multiple backends. If you’re already using Elastic Stack, the official agent may be a better fit despite requiring manual Laravel instrumentation.
- How do I configure the agent to work with Elastic APM Server v8.x?
- Check the Elastic APM Server documentation for API changes in v8.x, as the agent may need adjustments to its HTTP endpoint or payload format. Start with the default config and test in a staging environment. If issues arise, inspect the agent’s network requests to Elastic APM Server for compatibility gaps.
- Can I use this agent for Laravel Vapor or serverless deployments?
- Yes, but with manual setup. Instrument your Lambda functions or Vapor routes using `Span::start()` and ensure the agent’s HTTP client can reach your Elastic APM Server. Monitor cold-start latency, as serverless environments may introduce variability in telemetry collection.
- What’s the migration path if this package is abandoned?
- Audit your instrumentation code and replace `philkra/elastic-apm-php-agent` with **elastic/apm-agent-php** or **OpenTelemetry PHP**. The core concepts (transactions, spans) are similar, so refactoring should be straightforward. Test thoroughly, as API differences may require adjustments to context or metadata handling.
- How do I test APM instrumentation in a Laravel application?
- Use Laravel’s HTTP tests to simulate requests and verify transactions appear in Elastic APM. For CLI commands, test Artisan instrumentation with `Artisan::call()`. Mock external calls (e.g., database queries) to ensure spans are captured. Validate error reporting by throwing exceptions in test routes and checking Elastic APM for stack traces.