Skip to content

Commit

Permalink
Support aspect to GuzzleHttp\Client::request() (#5996)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Aug 4, 2023
1 parent 8d854fe commit d2848d8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Aspect/HttpClientAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HttpClientAspect extends AbstractAspect
use SpanStarter;

public array $classes = [
Client::class . '::request',
Client::class . '::requestAsync',
];

Expand All @@ -47,6 +48,10 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
if (isset($options['no_aspect']) && $options['no_aspect'] === true) {
return $proceedingJoinPoint->process();
}
// Disable the aspect for the requestAsync method.
if ($proceedingJoinPoint->methodName == 'request') {
$proceedingJoinPoint->arguments['keys']['options']['no_aspect'] = true;
}
$arguments = $proceedingJoinPoint->arguments;
$method = $arguments['keys']['method'] ?? 'Null';
$uri = $arguments['keys']['uri'] ?? 'Null';
Expand Down

0 comments on commit d2848d8

Please sign in to comment.