Skip to content

Commit

Permalink
Add config option to disable url tagging of automatic request timing …
Browse files Browse the repository at this point in the history
…metrics
  • Loading branch information
nekodex committed Jul 20, 2018
1 parent a77576c commit 9230b0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions config/datadog-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Middleware/LaravelDatadogMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 9230b0b

Please # to comment.