counter, gauge types).memory_get_usage() may include shared memory (e.g., OPcache), which could skew route-level metrics. Clarification needed on granularity (e.g., per-request vs. cumulative).| Risk | Mitigation Strategy |
|---|---|
| Performance Overhead | Benchmark with prometheus_client_php disabled to quantify impact. Use Laravel Debugbar for comparison. |
| Metric Cardinality Explosion | Limit labels (e.g., exclude route for high-cardinality paths like API v2 endpoints). |
| Prometheus Scrape Failures | Implement health checks for the /metrics endpoint and alert on scrape errors. |
| Laravel Version Drift | Pin symfony/http-kernel and prometheus_client_php versions to avoid breaking changes. |
| Custom Metrics Complexity | Document a metric extension guide for dev teams to avoid ad-hoc instrumentation. |
/metrics endpoint under load?user_id)?ext-prometheus.app/Http/Kernel.php or as a global middleware for all routes.curl http://localhost:8000/metrics and promtool check.scrape_configs:
- job_name: 'laravel_app'
static_configs:
- targets: ['laravel-app:8000']
/health).// app/Http/Kernel.php
protected $middleware = [
\Vdm\PrometheusBundle\Middleware\MetricsMiddleware::class,
];
| Component | Compatibility Notes |
|---|---|
| Laravel Version | Tested on 8.x/9.x. May require adjustments for 10.x (Symfony 6+) due to kernel changes. |
| PHP Version | Requires PHP 7.4+. Avoid PHP 8.0+ JIT optimizations if memory metrics are critical. |
| Prometheus | Works with v2.20+. Use prometheus_client_php v0.10+ for latest features. |
| Caching | Metrics are real-time; avoid caching the /metrics endpoint. |
| Async Jobs | Metrics won’t capture queue workers. Use prometheus_client_php directly in jobs. |
composer require 3slab/vdm-prometheus-bundle
php artisan vendor:publish --tag="vdm-prometheus-bundle"
config/packages/vdm_prometheus.yaml (e.g., disable routes):
vdm_prometheus:
enabled_routes: ['api/*']
/metrics endpoint returns data.prometheus --version).KernelEvents::REQUEST).CollectorRegistry.3slab/vdm-prometheus-bundle for breaking changes (low risk due to MIT license).prometheus_client_php to a stable version (e.g., ^0.10) to avoid metric schema drift.METRICS.md file.route to endpoint).prometheus_client_php has 100+ stars but infrequent releases).prometheus --web.enable-lifecycle to debug label explosion.memory_get_usage() with memory_get_peak_usage().promtool check rules for alerting validation.php artisan route:list to verify enabled routes.How can I help you explore Laravel packages today?