Skip to content

Commit

Permalink
[symfony] Fix: Set span status according to otel convention (#308)
Browse files Browse the repository at this point in the history
* Only set error status if we know the response code is 500 or higher.

* fix linting error
  • Loading branch information
technimad-splunk authored Oct 22, 2024
1 parent 78a04ce commit cf610d5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Instrumentation/Symfony/src/SymfonyInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
},
Expand Down

0 comments on commit cf610d5

Please sign in to comment.