From 9230b0ba162090c7445f5ac9621d652dec691bdb Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Fri, 20 Jul 2018 15:03:20 +0900 Subject: [PATCH] Add config option to disable url tagging of automatic request timing metrics --- config/datadog-helper.php | 11 +++++++++++ src/Middleware/LaravelDatadogMiddleware.php | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config/datadog-helper.php b/config/datadog-helper.php index e6ef455..904e13c 100644 --- a/config/datadog-helper.php +++ b/config/datadog-helper.php @@ -34,6 +34,17 @@ 'statsd_port' => 8125, + /* + |-------------------------------------------------------------------------- + | Disable tagging request durations with url + |-------------------------------------------------------------------------- + | + | Sites with large numbers of unique URIs can cause excessive unique tags for a metric which results + | in Datadog being unhappy (to the point of being unresponsive). + | + */ + 'middleware_disable_url_tag' => false, + /* |-------------------------------------------------------------------------- | Transport diff --git a/src/Middleware/LaravelDatadogMiddleware.php b/src/Middleware/LaravelDatadogMiddleware.php index 9a772c6..49a0a38 100644 --- a/src/Middleware/LaravelDatadogMiddleware.php +++ b/src/Middleware/LaravelDatadogMiddleware.php @@ -40,10 +40,13 @@ protected static function logDuration(Request $request, Response $response, $sta $duration = microtime(true) - $startTime; $tags = [ - "url" => $request->getSchemeAndHttpHost() . $request->getRequestUri(), "status_code" => $response->getStatusCode() ]; + if (!config('datadog-helper.middleware_disable_url_tag', false)) { + $tags["url"] = $request->getSchemeAndHttpHost() . $request->getRequestUri(); + } + Datadog::timing('request_time', $duration, 1, $tags); } }