[PHP] When to call GetConnection

Thank you for your supporting.

I have a more question: When you need to call getConnection?

Temporary I think that you need to call method_exists to verify first. How do you think?

@iwamoto thank you for reaching out! Can you provide some more detail about your question? I don’t think that getConnection is a NewRelic call, but using method_exists is definitely an advisable best-practice.

I’m sorry for late @scandela

My source code is simple like this:

$client  = new \GuzzleHttp\Client();
$request = $client->get($this->url, [
    'json' => [
        'app_name'    => config('app.name'),
        'campaign_id' => $campaignId,
    ],
]);

If I don’t install NR Agent, it works well.
But with NR Agent, the following exception throws randomly. The stack trace shows that the error at this code: $client = new \GuzzleHttp\Client();

Magic request methods require a URI and optional options array
#0 TestService.php(236): GuzzleHttp\Client->__call('getConnection', Array)

So I think that getConnection is a NR call.

I’m using Laravel 6.6, PHP 5.2.7 on the CentOS server.

1 Like

hi @iwamoto, my apologies for my own late reply!

I do see that you were experiencing this in another thread with some customers also seeing odd Guzzle errors; I’m engaging Engineering to see if they have any fresh insights on these.

In the meantime, are you able to validate if this works properly with a newer version of PHP? Our Agent only supports PHP as far back as v5.3, so you may see some unexpected results on 5.2. Our full compatibility lists are here: PHP agent compatibility and requirements

1 Like

Hi @scandela,

Whilst I’m not the original poster, we’re experiencing the same issue and are on PHP 7.3.

Hi @nick15

Thank you for bringing this to our attention. As my colleague @scandela mentioned, this is being investigated by the Engineering team.

I’m wondering if you could send me as a private message the logs of the PHP Agent and newrelic-daemon? They are usually located at /var/log/newrelic.

Thanks

Rodrigo

Hi Rodrigo,

I’ve sent you a private message with details and logs.

1 Like

Good to see you’re following up @nick15, if you get your issue resolved, feel free to share it on this thread for others who may have a similar issue :smiley:

1 Like

Hi all,

As the New Relic PHP Agent has now been open-sourced I thought I’d have a look to see what it’s doing and noticed the only place a getConnection call exists is within lib_predis.c, we are using Predis (version 1.1.1).

All our failed Guzzle calls occur after a Predis call as they’re only failing when they’re used in Laravel’s queue system.

My guess would be that the PHP agent is somehow confusing GuzzleHttp\Client with Predis\Client. I’m not sure why some are failing and others aren’t, but hopefully that provides some help.

@iwamoto are you also using Predis?

Thank you for providing this update @nick15. Hopefully this assists @iwamoto with their issue too.

@nick15 Exactly, I’m using predis. :cry:

Did you have a way to prevent this yet?

@nmcnamara Could you talk with NR developer guys about this problem?

@iwamoto Not way to prevent it yet. At the moment we’ve just disable New Relic for all of our queued jobs which has prevented the errors but it’s not really a long-term solution as it defeats the point of New Relic.

We’re investigating moving to PhpRedis instead of using Predis which might fix the problem, but I’m not certain when we’re going to have time to do that.

I guess we could try and disable specifically the Guzzle or Predis New Relic integrations - Guzzle looks pretty easy to disable, but not sure about disabling Predis, there doesn’t look like an easy way to do it without renaming some Predis files (@nmcnamara, @rcorgozinho, @scandela would you happen to know a way to disable just the Predis instrumentation?)

@nick15 Thank you for your information.

We’re investigating moving to PhpRedis instead of using Predis which might fix the problem, but I’m not certain when we’re going to have time to do that.

Same thought with me, we can try. But I think this will not only occouce with predis & Guzzle.

Guzzle looks pretty easy to disable

Could you share how to disable Guzzle?

Sorry for the delay @iwamoto - it looks like you can disable it through the newrelic.ini file by adding newrelic.guzzle.enabled = false, here’s the documentation for it: https://docs.newrelic.com/docs/agents/php-agent/frameworks-libraries/guzzle#h2-disable-guzzle-support

1 Like

@nick15 I got it, Thank you so much for your helping.

@iwamoto let us know if it prevents the getConnection error