function WithSpanHandler::post
File
-
vendor/
open-telemetry/ api/ Instrumentation/ WithSpanHandler.php, line 49
Class
- WithSpanHandler
- Generic pre-hook and post-hook handlers for attribute-based auto instrumentation
Namespace
OpenTelemetry\API\InstrumentationCode
public static function post(mixed $target, array $params, mixed $result, ?Throwable $exception) : void {
$scope = Context::storage()->scope();
$scope?->detach();
if (!$scope || $scope->context() === Context::getCurrent()) {
return;
}
$span = Span::fromContext($scope->context());
if ($exception) {
$span->recordException($exception, [
'exception.escaped' => true,
]);
$span->setStatus(StatusCode::STATUS_ERROR, $exception->getMessage());
}
$span->end();
}