31 lines
649 B
PHP
31 lines
649 B
PHP
<?php
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Domnikl\Statsd\Client;
|
|
|
|
class StatsdMiddelware
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
/* @var $statsd \Domnikl\Statsd\Client */
|
|
$statsd = app(Client::class);
|
|
|
|
$statsd->count("request.all", 1);
|
|
|
|
/* @var $response \Illuminate\Http\Response */
|
|
$response = $next($request);
|
|
|
|
|
|
$statsd->count("request.".$response->getStatusCode(), 1);
|
|
|
|
return $response;
|
|
}
|
|
}
|