diff --git a/src/Aspect/HttpClientAspect.php b/src/Aspect/HttpClientAspect.php index 42699b5..40602ff 100644 --- a/src/Aspect/HttpClientAspect.php +++ b/src/Aspect/HttpClientAspect.php @@ -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)) { diff --git a/src/Listener/RequestTraceListener.php b/src/Listener/RequestTraceListener.php index 5cbf008..8a8b68f 100644 --- a/src/Listener/RequestTraceListener.php +++ b/src/Listener/RequestTraceListener.php @@ -75,7 +75,7 @@ protected function handleRequestTerminated(RequestTerminated $event): void $tracer = TracerContext::getTracer(); $span = TracerContext::getRoot(); - $span->setTag($this->spanTagManager->get('response', 'status_code'), $response->getStatusCode()); + $span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $response->getStatusCode()); if ($event->exception && $this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($event->exception)) { $this->appendExceptionToSpan($span, $exception = $event->exception); @@ -93,7 +93,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', 'code'), (string) $exception->getCode()); $span->setTag($this->spanTagManager->get('exception', 'message'), $exception->getMessage()); $span->setTag($this->spanTagManager->get('exception', 'stack_trace'), (string) $exception); } diff --git a/src/Middleware/TraceMiddleware.php b/src/Middleware/TraceMiddleware.php index 40009cc..92a816e 100644 --- a/src/Middleware/TraceMiddleware.php +++ b/src/Middleware/TraceMiddleware.php @@ -56,13 +56,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface if ($traceId = TracerContext::getTraceId()) { $response = $response->withHeader('Trace-Id', $traceId); } - $span->setTag($this->spanTagManager->get('response', 'status_code'), $response->getStatusCode()); + $span->setTag($this->spanTagManager->get('response', 'status_code'), (string) $response->getStatusCode()); } catch (Throwable $exception) { if ($this->switchManager->isEnable('exception') && ! $this->switchManager->isIgnoreException($exception)) { $this->appendExceptionToSpan($span, $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()); } throw $exception; } finally { @@ -76,7 +76,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', 'code'), (string) $exception->getCode()); $span->setTag($this->spanTagManager->get('exception', 'message'), $exception->getMessage()); $span->setTag($this->spanTagManager->get('exception', 'stack_trace'), (string) $exception); }