guzzle async and curl_multi auto-instrumentation
Describe the bug
Documentation says that curl extension will be auto instrumented and have distributed trace headers applied to any request. Using guzzlehttp/guzzle v7.3.0 with default curl handler, whilst making aync calls ($client->getAsync('example.com')->wait()), did not add distributed trace headers or create a span.
Whilst debugging this with @michaelhyatt I found that by default, guzzle uses both curl and curl_multi - and evidently uses curl_multi for async requests: https://github.com/guzzle/guzzle/blob/master/src/Utils.php#L89
If I force a plain curl handler, then I do get distributed trace headers:
<?php
$handler = new \GuzzleHttp\Handler\CurlHandler();
$stack = \GuzzleHttp\HandlerStack::create($handler);
$client = new \GuzzleHttp\Client(['handler' => $stack]);
$response = $client->getAsync('example.com')->wait();
echo $response->getBody()->getContents();
Secondly, the documentation also says that guzzle itself will be instrumented, but I see no signs of this happening.
OS: centos:7 plus debian:buster in docker PHP: 7.4.20 apm-agent-php: 1.1 (installed from rpm + deb)
To Reproduce Steps to reproduce the behavior:
- Use this script:
<?php
$client = new \GuzzleHttp\Client();
$response = $client->getAsync('example.com')->wait();
echo $response->getBody()->getContents();
- Then load the page/execute the script
- Then check traces in kibana
- You should see a transaction with a single span. However, if you use CurlHandler() only, you will see a child span for the http request.
Expected behavior Expect to see a transaction with 3 spans: parent, guzzle, curl.
Also worth noting: forcing the use of CurlHandler breaks guzzle's async feature, all requests happen sequentially.
This would be a great improvement, as curl_multi is also the default on the Symfony PSR18 client.
Big +1 from me and my team.