function StreamTransport::send
Overrides TransportInterface::send
File
-
vendor/
open-telemetry/ sdk/ Common/ Export/ Stream/ StreamTransport.php, line 46
Class
- StreamTransport
- @internal
Namespace
OpenTelemetry\SDK\Common\Export\StreamCode
public function send(string $payload, ?CancellationInterface $cancellation = null) : FutureInterface {
if (!$this->stream) {
return new ErrorFuture(new BadMethodCallException('Transport closed'));
}
set_error_handler(static function (int $errno, string $errstr, string $errfile, int $errline) : bool {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
try {
$bytesWritten = fwrite($this->stream, $payload);
} catch (Throwable $e) {
return new ErrorFuture($e);
} finally {
restore_error_handler();
}
if ($bytesWritten !== strlen($payload)) {
return new ErrorFuture(new RuntimeException(sprintf('Write failure, wrote %d of %d bytes', $bytesWritten, strlen($payload))));
}
return new CompletedFuture(null);
}