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; },