elastic / elastic/apm-agent-php

guzzle async and curl_multi auto-instrumentation

Open
#428 4 comments 13 reactions 1 assignee Claimed by @SergeyKleyman View on GitHub
agent-php bug near term candidate priority: medium triaged
Dominant language
PHP
Stars
268
Forks
86
PR merge metrics
No merged PRs in 30d

Description

**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
$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:
1. Use this script:
```php
getAsync('example.com')->wait();
echo $response->getBody()->getContents();
```
2. Then load the page/execute the script
3. Then check traces in kibana
4. 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.