m6web/statsd
Simple StatsD client for PHP. Send counters, gauges, timers and sets to a StatsD/Graphite backend with minimal overhead. Designed for easy integration and straightforward API to instrument apps and collect metrics.
m6web/statsd package is a lightweight wrapper for interacting with StatsD, a popular metrics aggregation system (e.g., for monitoring application performance, request rates, or custom metrics). It fits well in architectures where:
etsy/statsd or prom/statsd_exporter).Illuminate\Contracts\Container\Container).ext-sockets for UDP, ext-json for serialization).mockery or a local statsd Docker container).prometheus/client_php) be a better fit for long-term observability?AppServiceProvider:
$this->app->singleton(Statsd::class, function ($app) {
return new \M6Web\Statsd\Statsd('statsd.example.com', 8125);
});
StatsdFacade) for cleaner syntax:
Statsd::increment('api.requests');
Statsd::timing('db.query', 150);
League\Container) or instantiate manually:
$statsd = new \M6Web\Statsd\Statsd('statsd.example.com');
docker run -d --name statsd -p 8125:8125/udp -p 8126:8126 prom/statsd-exporter
statsd_exporter to forward metrics.app.name:metric.type).ext-sockets is enabled (php -m | grep sockets).composer.json:
"m6web/statsd": "^1.0"
// In a controller
Statsd::increment('api.users.created');
Statsd::timing('api.users.created.ms', $executionTime);
Statsd::setSampleRate(0.1) for 10% sampling).Statsd::gauge('queue.size', 42, ['queue' => 'orders'])).ping checks).Statsd::setDebug(true) to log raw UDP packets.8125.app.name:counter vs. app.name:gauge).Statsd::setSampleRate(0.01); // 1% sampling
| Failure Scenario | Impact |
How can I help you explore Laravel packages today?