Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a config option to allow disabling of url tagging if the middleware request timings #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}