Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public static function register(): void
return;
}

if ($response->getStatusCode() >= Response::HTTP_BAD_REQUEST) {
// Do not set error status on server spans for 4xx responses
if (!$span->getKind(SpanKind::KIND_SERVER) && $response->getStatusCode() >= Response::HTTP_BAD_REQUEST) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only seems possible if this is a subrequest (internal redirect) in which case span kind is INTERNAL. I assume it was an intentional choice to use error status specifically for 400 codes from internal redirects, as the specification does not cover this scenario at all. Since you already have a comment here, perhaps it could mention that this case is for subrequests/internal spans.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. This case can only happen with span kind Internal. The intention was to have this case mainly for client span kinds. Which can't happen here.
I will remove this case, to ONLY set error status on >= 500 status codes. This is the same behaviour as implemented in Laravel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok to me, can it be tested by adding/modifying our existing tests?

$span->setStatus(StatusCode::STATUS_ERROR);
}
// Do set error status on all spans for 5xx responses
if ($response->getStatusCode() >= Response::HTTP_INTERNAL_SERVER_ERROR) {
$span->setStatus(StatusCode::STATUS_ERROR);
}
$span->setAttribute(TraceAttributes::HTTP_RESPONSE_STATUS_CODE, $response->getStatusCode());
Expand Down