- Can I use this bundle directly in a Laravel app, or is it only for Symfony?
- This bundle is designed for Symfony, so it requires a bridge or adapter layer to work in Laravel. You’ll need to manually translate Symfony’s kernel events (like `kernel.request`) into Laravel’s middleware or event system. Consider using a Symfony microkernel alongside Laravel or building custom middleware to dispatch metrics events.
- What Laravel versions are compatible with this bundle?
- The bundle supports PHP 8.2–8.5, which aligns with Laravel 10.x and 11.x. However, since it’s Symfony-focused, you’ll need to handle integration manually. Test thoroughly in your Laravel version to ensure event compatibility.
- How do I ignore specific routes from metrics collection?
- Configure the `ignored_routes` option in your Symfony bundle config (e.g., `artprima_prometheus_metrics.ignored_routes`). For Laravel, you’ll need to map these to Laravel route names or middleware exclusions, as the bundle doesn’t natively support Laravel’s routing system.
- Does this bundle support custom metrics beyond HTTP requests?
- Yes, the bundle allows custom metrics via collectors. For Laravel, you’ll need to extend the `MetricsCollectorInterface` or create middleware to inject Laravel-specific metrics (e.g., Eloquent queries, queue jobs) into the Prometheus client.
- Can I store metrics in Redis instead of APCu?
- The bundle supports Redis storage via `promphp/prometheus_client_php`. Configure it in your Symfony setup, but ensure your Laravel app also uses Redis (e.g., with `predis` or `php-redis`) for shared access. APCu is simpler but less scalable for distributed Laravel apps.
- How do I add custom labels to HTTP metrics in Laravel?
- Use the `custom_labels` config in Symfony’s bundle to define labels like `action`. For Laravel, you’ll need to attach these labels via middleware or event listeners that modify the Symfony `RequestEvent` or `ResponseEvent` before metrics are collected.
- Will this bundle work with Laravel’s queue system (e.g., Horizon)?
- Not natively, but you can extend it by creating a custom collector that listens to Laravel’s `job.processing` or `job.failed` events. Inject these metrics into the Prometheus client manually, similar to how you’d handle HTTP metrics.
- Are there performance concerns with collecting metrics in production?
- Metrics collection adds minimal overhead, but Redis storage may introduce latency. Benchmark your setup with tools like Blackfire or Xdebug. For high-traffic apps, consider in-memory storage (e.g., APCu) or batching metrics collection.
- How do I visualize Laravel-specific metrics in Grafana?
- Use existing Prometheus dashboards and adapt them for Laravel metrics (e.g., queue depth, API latency). Create custom Grafana panels for Laravel-specific collectors. The bundle’s metrics will appear in Prometheus as long as they’re properly labeled.
- What alternatives exist for Prometheus metrics in Laravel?
- Consider `spatie/laravel-prometheus` (Laravel-native) or `robmorgan/phpmetrics` (PHP-agnostic). These avoid Symfony dependencies and integrate directly with Laravel’s middleware/events. Evaluate based on your need for Symfony compatibility or pure Laravel simplicity.