Skip to content

Commit 751e900

Browse files
Fixed bug that the jaeger cannot show the http code when using tracer. (#6321)
Co-authored-by: 李铭昕 <[email protected]>
1 parent c01f1de commit 751e900

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/Aspect/HttpClientAspect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
7777
try {
7878
$result = $proceedingJoinPoint->process();
7979
if ($result instanceof ResponseInterface) {
80-
$span->setTag($this->spanTagManager->get('http_client', 'http.status_code'), $result->getStatusCode());
80+
$span->setTag($this->spanTagManager->get('http_client', 'http.status_code'), (string) $result->getStatusCode());
8181
}
8282
} catch (Throwable $e) {
8383
if ($this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($e)) {

src/Listener/RequestTraceListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function handleRequestTerminated(RequestTerminated $event): void
7575

7676
$tracer = TracerContext::getTracer();
7777
$span = TracerContext::getRoot();
78-
$span->setTag($this->spanTagManager->get('response', 'status_code'), $response->getStatusCode());
78+
$span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $response->getStatusCode());
7979

8080
if ($event->exception && $this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($event->exception)) {
8181
$this->appendExceptionToSpan($span, $exception = $event->exception);
@@ -93,7 +93,7 @@ protected function appendExceptionToSpan(Span $span, Throwable $exception): void
9393
{
9494
$span->setTag('error', true);
9595
$span->setTag($this->spanTagManager->get('exception', 'class'), get_class($exception));
96-
$span->setTag($this->spanTagManager->get('exception', 'code'), $exception->getCode());
96+
$span->setTag($this->spanTagManager->get('exception', 'code'), (string) $exception->getCode());
9797
$span->setTag($this->spanTagManager->get('exception', 'message'), $exception->getMessage());
9898
$span->setTag($this->spanTagManager->get('exception', 'stack_trace'), (string) $exception);
9999
}

src/Middleware/TraceMiddleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5656
if ($traceId = TracerContext::getTraceId()) {
5757
$response = $response->withHeader('Trace-Id', $traceId);
5858
}
59-
$span->setTag($this->spanTagManager->get('response', 'status_code'), $response->getStatusCode());
59+
$span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $response->getStatusCode());
6060
} catch (Throwable $exception) {
6161
if ($this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($exception)) {
6262
$this->appendExceptionToSpan($span, $exception);
6363
}
6464
if ($exception instanceof HttpException) {
65-
$span->setTag($this->spanTagManager->get('response', 'status_code'), $exception->getStatusCode());
65+
$span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $exception->getStatusCode());
6666
}
6767
throw $exception;
6868
} finally {
@@ -76,7 +76,7 @@ protected function appendExceptionToSpan(Span $span, Throwable $exception): void
7676
{
7777
$span->setTag('error', true);
7878
$span->setTag($this->spanTagManager->get('exception', 'class'), get_class($exception));
79-
$span->setTag($this->spanTagManager->get('exception', 'code'), $exception->getCode());
79+
$span->setTag($this->spanTagManager->get('exception', 'code'), (string) $exception->getCode());
8080
$span->setTag($this->spanTagManager->get('exception', 'message'), $exception->getMessage());
8181
$span->setTag($this->spanTagManager->get('exception', 'stack_trace'), (string) $exception);
8282
}

0 commit comments

Comments
 (0)