Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
/ hyperf-tracer Public archive
forked from hyperf/tracer

Commit

Permalink
clear uri on http aspect (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
leocarmo authored Oct 11, 2022
1 parent 4aab56f commit e035241
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Aspect/HttpClientAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
use OpenTracing\Tracer;
use Psr\Http\Message\ResponseInterface;
use Throwable;

use const OpenTracing\Formats\TEXT_MAP;
use const OpenTracing\Tags\SPAN_KIND_RPC_CLIENT;

/** @Aspect */
class HttpClientAspect implements AroundInterface
Expand Down Expand Up @@ -81,7 +81,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
'%s %s/%s',
$method,
rtrim((string) ($base_uri ?? ''), '/'),
ltrim(parse_url($uri, PHP_URL_PATH) ?? '', '/')
ltrim(parse_url($this->clearUri($uri), PHP_URL_PATH) ?? '', '/')
)
);

Expand Down Expand Up @@ -119,6 +119,15 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
return $result;
}

protected function clearUri(string $uri): string
{
return preg_replace(
'/\/[0-9]+\//',
'/****/',
$uri
);
}

private function onFullFilled(Span $span): callable
{
return function (ResponseInterface $response) use ($span) {
Expand Down

0 comments on commit e035241

Please sign in to comment.