arquivei / laravel-prometheus-exporter

A Prometheus exporter for Laravel and Lumen
MIT License
10 stars 9 forks source link

Suggestion: Don't throw in the route middleware if the storage errors #33

Open Radiergummi opened 2 years ago

Radiergummi commented 2 years ago

Currently, if Redis isn't reachable, a StorageException is thrown by the Redis adapter. This might happen in containerised deployments, for example, where the Redis container is not ready yet. If that's the case, and Prometheus Laravel Route Middleware is enabled, the histogram observation will throw the exception and cause every request to fail until Redis is available.

I'm a firm believer in that monitoring infrastructure should never bring an application down. Metrics are never as important as customer requests. If you like it this way, there should be at least a configuration option to catch and log the error instead of throwing

ru90 commented 2 years ago

Facing same issue in application. Try to handle it Handlers but ultimately it failed request. Is there any solution for this?

Radiergummi commented 2 years ago

I solved it by writing my own middleware that wraps the calls in try-catch, but that isn't a good solution.