Skip to content

A workaround to report Guzzle requests with correct Host Http header in NewRelic.

Notifications You must be signed in to change notification settings

BedrockStreaming/newrelic-guzzle-http-host

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

newrelic-guzzle-http-host

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.

About

A workaround to report Guzzle requests with correct Host Http header in NewRelic.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages