Skip to content

Commit

Permalink
Merge pull request #8 from nekodex/feature/disable-middleware-tagging…
Browse files Browse the repository at this point in the history
…-option

Add a config option to allow disabling of url tagging if the middleware request timings
  • Loading branch information
chaseconey authored Jul 23, 2018
2 parents a77576c + 9230b0b commit 35a2ccf
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 35a2ccf

Please # to comment.