Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple of code tidies left over from PR #1499 #1502

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/Contrib/Grpc/GrpcTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -81,13 +82,12 @@ public function create(
$opts,
$method,
$headers,
(int) ($timeout * 1000),
(int) ($timeout * ClockInterface::MILLIS_PER_SECOND),
Copy link
Contributor

Choose a reason for hiding this comment

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

🤦 sorry, just realised that this causes a dependency on API 1.2.1 (see here).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ugh, yeah. Let's create a local const in GrpcTransportFactory for now.

);
}

private static function createOpts(
$compression,
float $timeout,
int $maxRetries,
int $retryDelay,
): array {
Expand Down Expand Up @@ -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
Expand Down
Loading