From 904d76a305595e58c0faa8e1e435e27543eae2d7 Mon Sep 17 00:00:00 2001 From: Jon Bates Date: Wed, 5 Feb 2025 13:52:44 +0000 Subject: [PATCH] A couple of code tidies left over from PR #1499 --- src/Contrib/Grpc/GrpcTransportFactory.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Contrib/Grpc/GrpcTransportFactory.php b/src/Contrib/Grpc/GrpcTransportFactory.php index 4c03562f4..3317e5d33 100644 --- a/src/Contrib/Grpc/GrpcTransportFactory.php +++ b/src/Contrib/Grpc/GrpcTransportFactory.php @@ -12,6 +12,7 @@ use InvalidArgumentException; use function json_encode; use OpenTelemetry\API\Behavior\LogsMessagesTrait; +use OpenTelemetry\API\Common\Time\ClockInterface; use OpenTelemetry\Contrib\Otlp\ContentTypes; use OpenTelemetry\SDK\Common\Export\TransportFactoryInterface; use OpenTelemetry\SDK\Common\Export\TransportInterface; @@ -62,7 +63,7 @@ public function create( throw new InvalidArgumentException(sprintf('Endpoint path is not a valid GRPC method "%s"', $method)); } - $opts = self::createOpts($compression, $timeout, $maxRetries, $retryDelay); + $opts = self::createOpts($compression, $maxRetries, $retryDelay); /** @psalm-suppress PossiblyNullArgument */ $opts['credentials'] = $scheme === 'http' ? ChannelCredentials::createInsecure() @@ -81,13 +82,12 @@ public function create( $opts, $method, $headers, - (int) ($timeout * 1000), + (int) ($timeout * ClockInterface::MILLIS_PER_SECOND), ); } private static function createOpts( $compression, - float $timeout, int $maxRetries, int $retryDelay, ): array { @@ -119,8 +119,8 @@ private static function createOpts( ], 'retryPolicy' => [ 'maxAttempts' => $maxRetries, - 'initialBackoff' => sprintf('%0.3fs', $retryDelay / 1000), - 'maxBackoff' => sprintf('%0.3fs', ($retryDelay << $maxRetries - 1) / 1000), + 'initialBackoff' => sprintf('%0.3fs', $retryDelay / ClockInterface::MILLIS_PER_SECOND), + 'maxBackoff' => sprintf('%0.3fs', ($retryDelay << $maxRetries - 1) / ClockInterface::MILLIS_PER_SECOND), 'backoffMultiplier' => 2, 'retryableStatusCodes' => [ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md#otlpgrpc-response