Skip to content

Commit

Permalink
处理http code是整型上报后显示错误
Browse files Browse the repository at this point in the history
  • Loading branch information
kalami committed Nov 24, 2023
1 parent c01f1de commit 0a5e224
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Aspect/HttpClientAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
try {
$result = $proceedingJoinPoint->process();
if ($result instanceof ResponseInterface) {
$span->setTag($this->spanTagManager->get('http_client', 'http.status_code'), $result->getStatusCode());
$span->setTag($this->spanTagManager->get('http_client', 'http.status_code'), (string) $result->getStatusCode());
}
} catch (Throwable $e) {
if ($this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($e)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/RequestTraceListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function handleRequestTerminated(RequestTerminated $event): void
$this->appendExceptionToSpan($span, $exception = $event->exception);

if ($exception instanceof HttpException) {
$span->setTag($this->spanTagManager->get('response', 'status_code'), $exception->getStatusCode());
$span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $exception->getStatusCode());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/TraceMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function appendExceptionToSpan(Span $span, Throwable $exception): void
$span->setTag('error', true);
$span->setTag($this->spanTagManager->get('exception', 'class'), get_class($exception));
$span->setTag($this->spanTagManager->get('exception', 'code'), $exception->getCode());
$span->setTag($this->spanTagManager->get('exception', 'message'), $exception->getMessage());
$span->setTag($this->spanTagManager->get('exception', 'message'), (string) $exception->getMessage());
$span->setTag($this->spanTagManager->get('exception', 'stack_trace'), (string) $exception);
}

Expand Down

0 comments on commit 0a5e224

Please sign in to comment.