From 5526599c12b73a5f9b8546742f9c88650477fd2b Mon Sep 17 00:00:00 2001 From: erwin vrolijk Date: Fri, 18 Oct 2024 13:16:45 +0200 Subject: [PATCH] Only set error status if we know the response code is 500 or higher. --- src/Instrumentation/Symfony/src/SymfonyInstrumentation.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php index 7d511488..bb4c3413 100644 --- a/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php +++ b/src/Instrumentation/Symfony/src/SymfonyInstrumentation.php @@ -104,7 +104,9 @@ public static function register(): void $span->recordException($exception, [ TraceAttributes::EXCEPTION_ESCAPED => true, ]); - $span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage()); + if(null !== $response && $response->getStatusCode() >= Response::HTTP_INTERNAL_SERVER_ERROR) { + $span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage()); + } } if (null === $response) { @@ -159,8 +161,7 @@ public static function register(): void Span::getCurrent() ->recordException($throwable, [ TraceAttributes::EXCEPTION_ESCAPED => true, - ]) - ->setStatus(StatusCode::STATUS_ERROR, $throwable->getMessage()); + ]); return $params; },