Skip to content

Commit 2d2c37b

Browse files
authored
fix guzzle hook class (open-telemetry#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.
1 parent cf610d5 commit 2d2c37b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Instrumentation/Guzzle/src/GuzzleInstrumentation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace OpenTelemetry\Contrib\Instrumentation\Guzzle;
66

77
use function get_cfg_var;
8-
use GuzzleHttp\ClientInterface;
8+
use GuzzleHttp\Client;
99
use GuzzleHttp\Promise\PromiseInterface;
1010
use OpenTelemetry\API\Globals;
1111
use OpenTelemetry\API\Instrumentation\CachedInstrumentation;
@@ -35,9 +35,9 @@ public static function register(): void
3535
);
3636

3737
hook(
38-
ClientInterface::class,
38+
Client::class,
3939
'transfer',
40-
pre: static function (ClientInterface $client, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): array {
40+
pre: static function (Client $client, array $params, string $class, string $function, ?string $filename, ?int $lineno) use ($instrumentation): array {
4141
$request = $params[0];
4242
assert($request instanceof RequestInterface);
4343

@@ -84,7 +84,7 @@ public static function register(): void
8484

8585
return [$request];
8686
},
87-
post: static function (ClientInterface $client, array $params, PromiseInterface $promise, ?Throwable $exception): void {
87+
post: static function (Client $client, array $params, PromiseInterface $promise, ?Throwable $exception): void {
8888
$scope = Context::storage()->scope();
8989
$scope?->detach();
9090

0 commit comments

Comments
 (0)