From c44eee50a0495995f39ffb994bdb299b60415c9f Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 24 Oct 2024 10:18:52 +1100 Subject: [PATCH] fix guzzle hook class (#310) Guzzle auto-instrumentation is incorrectly hooking ClientInterface::transfer when the actual method is Client::transfer. There has never been a ClientInterface::transfer in guzzle... It current works, probably more by accident than design, since the extension will still run a hook method against an implementing class even if the method is not defined in the interface. --- src/GuzzleInstrumentation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GuzzleInstrumentation.php b/src/GuzzleInstrumentation.php index 39f1016..e258153 100644 --- a/src/GuzzleInstrumentation.php +++ b/src/GuzzleInstrumentation.php @@ -5,7 +5,7 @@ namespace OpenTelemetry\Contrib\Instrumentation\Guzzle; use function get_cfg_var; -use GuzzleHttp\ClientInterface; +use GuzzleHttp\Client; use GuzzleHttp\Promise\PromiseInterface; use OpenTelemetry\API\Globals; use OpenTelemetry\API\Instrumentation\CachedInstrumentation; @@ -35,9 +35,9 @@ public static function register(): void ); hook( - ClientInterface::class, + Client::class, 'transfer', - pre: static function (ClientInterface $client, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): array { + pre: static function (Client $client, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): array { $request = $params[0]; assert($request instanceof RequestInterface); @@ -84,7 +84,7 @@ public static function register(): void return [$request]; }, - post: static function (ClientInterface $client, array $params, PromiseInterface $promise, ?Throwable $exception): void { + post: static function (Client $client, array $params, PromiseInterface $promise, ?Throwable $exception): void { $scope = Context::storage()->scope(); $scope?->detach();