Skip to content

Commit 6123ef4

Browse files
[Symfony] Fix: Set span status according to otel convention (#295)
* Set span status according to otel convention The span status was always set to error for responses with status code 400 and up. According to the otel semantic conventions, for 4xx status, the span status MUST be left unset for spans with SpanKind.SERVER This commit adds the logic to implement this behaviour. Ref: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status * Do not set error status on internal spans with status 4xx Internal spans could have an error status, while the accompanying server span didn't have an error status. This changes this behaviour to ONLY set error status on requests with status code >= 500 regardless of the span kind.
1 parent e2ba8fa commit 6123ef4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Instrumentation/Symfony/src/SymfonyInstrumentation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function register(): void
113113
return;
114114
}
115115

116-
if ($response->getStatusCode() >= Response::HTTP_BAD_REQUEST) {
116+
if ($response->getStatusCode() >= Response::HTTP_INTERNAL_SERVER_ERROR) {
117117
$span->setStatus(StatusCode::STATUS_ERROR);
118118
}
119119
$span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode());

0 commit comments

Comments
 (0)