bedrockstreaming / newrelic-guzzle-http-host
A workaround to report Guzzle requests with correct Host Http header in NewRelic.
Installs: 46 944
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 16
Forks: 0
Open Issues: 0
This package is auto-updated.
Last update: 2024-10-27 19:45:14 UTC
README
A workaround to report Guzzle requests with correct Host Http header in NewRelic.
In some case, you may use a common proxy for several external calls to various hosts,
using the standard Host
to route your requests.
Unfortunatly, since all of these calls use the same uri, NewRelic will report them as external calls to the same target.
This small script provide a workaround to report the correct endpoint according to the HTTP Host
header.
⚠️ This library is a workaround relying on the current implementation of the newrelic extension! Test it carefully before to use it with a new extension release. See explanations section below for more details.
ℹ️An official feature request has been submitted to NewRelic team.
Installation
composer require bedrockstreaming/newrelic-guzzle-http-host
That's all! The script is automatically imported thanks to Composer autoloader.
ℹ️ You can also copy the content of newrelic_hook.php
directly in your project.
Explanations
The newrelic extension defines a Php function, a Guzzle middleware to report some metrics on each requests sent from Php.
Fortunately, the extension defines this function only if it doesn't already exist… then this workaround define this function before newrelic does 😅.
Original code is copied in this function, but we create a new http requests dedicated to NewRelic reporting, resolving the Http HOST
header.
The original request used by Guzzle stays unchanged.