• English日本語한국어
  • Log inStart now

PHP agent support for Guzzle

New Relic supports versions 3, 4, 5, 6 and 7 of the Guzzle HTTP client library with New Relic PHP agent version 7.0 or higher.

The Guzzle library allows both sequential and parallel requests. This page describes how each type of request will appear in the Summary page in the New Relic UI. To discover which call was the slowest, view the External Services page which displays timing for individual external calls.

Sequential requests

This PHP code makes multiple sequential requests with Guzzle:

$client = new \GuzzleHttp\Client;
$response = $client->get('http://YOUR_SITE.com/api/foo');
$client->delete('http://YOUR_SITE.com/api/foo/'.$response->getBody());

This code would appear in the New Relic UI as:

one.newrelic.com > All capabilities > APM & services > (select an app) > Overview > Web transactions time: Sequential requests with Guzzle in the New Relic UI.

Response time is shown as the dark blue line. The green web external time represents time spent in the Guzzle library. Because the requests were made sequentially, the response time is equal to the total time spent in PHP, MySQL, and web external activities.

Parallel requests

This PHP code makes multiple requests in parallel by unwrapping an array of promises:

$client = new \GuzzleHttp\Client;
$promises = [
$client->getAsync('http://YOUR_SITE.com/api/foo'),
$client->getAsync('http://YOUR_SITE.com/api/bar'),
$client->getAsync('http://YOUR_SITE.com/api/quux'),
];
\GuzzleHttp\Promise\unwrap($promises);

This code would appear in the New Relic UI as:

one.newrelic.com > All capabilities > APM & services > (select an app) > Summary > Web transactions time: Parallel requests with Guzzle in the New Relic UI

The green web external time represents time spent in the Guzzle library. Because the requests were performed asynchronously, the total time spent in PHP, MySQL, and web external is greater than the response time.

Timing with Guzzle 6 and 7

Unlike previous versions, Guzzle 6 and 7 do not generate an event when a request is sent. Instead, the agent begins timing a request when the request object is created. If a request object is created and additional work is done before sending, New Relic may report that the request took longer than it actually did.

Disable Guzzle support

To disable Guzzle support:

  1. Add newrelic.guzzle.enabled = false to your newrelic.ini file.
  2. Restart your web server (Apache, Nginx, PHP-FPM, etc.).
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.