Skip to content

Commit 8e896fe

Browse files
authored
Add: Ignore URI config (#18)
1 parent aa2d7db commit 8e896fe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Aspect/HttpClientMetricAspect.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
4545
$uri = $arguments['keys']['uri'] ?? '';
4646
$host = $base_uri === null ? (parse_url($uri, PHP_URL_HOST) ?? '') : $base_uri->getHost();
4747

48+
$uri = $this->shouldIgnoreUri($instance)
49+
? '<IGNORED>'
50+
: SupportUri::sanitize(parse_url($uri, PHP_URL_PATH) ?? '/');
51+
4852
$labels = [
49-
'uri' => SupportUri::sanitize(parse_url($uri, PHP_URL_PATH) ?? '/'),
53+
'uri' => $uri,
5054
'host' => $host,
5155
'method' => $method,
5256
'http_status_code' => '200',
@@ -66,6 +70,11 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
6670
return $result;
6771
}
6872

73+
private function shouldIgnoreUri(Client $instance): bool
74+
{
75+
return $instance->getConfig('ignore_uri') === true;
76+
}
77+
6978
private function onFullFilled(Timer $timer, array $labels): callable
7079
{
7180
return function (ResponseInterface $response) use ($timer, $labels) {

0 commit comments

Comments
 (0)