diff --git a/CHANGELOG.md b/CHANGELOG.md index 23387b0..41a9348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,11 @@ # Changelog - - ## v2.0.0-beta3 ### Changed - Moved "instrument" to the root level +- The `AdaptiveInteractor` is now the default interactor. ### Fixed diff --git a/DependencyInjection/EkinoNewRelicExtension.php b/DependencyInjection/EkinoNewRelicExtension.php index 07b881d..d275e1c 100644 --- a/DependencyInjection/EkinoNewRelicExtension.php +++ b/DependencyInjection/EkinoNewRelicExtension.php @@ -16,6 +16,7 @@ use Ekino\NewRelicBundle\Listener\CommandListener; use Ekino\NewRelicBundle\Listener\RequestListener; use Ekino\NewRelicBundle\Listener\ResponseListener; +use Ekino\NewRelicBundle\NewRelic\AdaptiveInteractor; use Ekino\NewRelicBundle\NewRelic\BlackholeInteractor; use Ekino\NewRelicBundle\NewRelic\Config; use Ekino\NewRelicBundle\NewRelic\LoggingInteractorDecorator; @@ -145,12 +146,17 @@ private function getInteractorServiceId(array $config): string return BlackholeInteractor::class; } - if (isset($config['interactor'])) { - return $config['interactor']; + if (!isset($config['interactor'])) { + // Fallback on AdaptiveInteractor. + return AdaptiveInteractor::class; } - // Fallback to see if the extension is loaded or not - return \extension_loaded('newrelic') ? NewRelicInteractor::class : BlackholeInteractor::class; + if ('auto' === $config['interactor']) { + // Check if the extension is loaded or not + return \extension_loaded('newrelic') ? NewRelicInteractor::class : BlackholeInteractor::class; + } + + return $config['interactor']; } private function getTransactionNamingServiceId(array $config): string diff --git a/README.md b/README.md index cae6da0..ad6bf00 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,22 @@ The bundle provide a [Capifony](http://capifony.org) recipe to automate the depl It makes one request per `app_name`, due roll-up names are not supported by Data REST API. +## Interactor services + +The config key`ekino_new_relic.interactor` will accept a service ID to a service implementing `NewRelicInteractorInterface`. +This bundle comes with a few services that may be suitable for you. + +| Configuration value | Description | +| ------------------- | ----------- | +| `Ekino\NewRelicBundle\NewRelic\AdaptiveInteractor` | This is the default interactor. It will check once per request if the NewRelic PHP extension is installed or not. It is a decorator for the `NewRelicInteractor` | +| `Ekino\NewRelicBundle\NewRelic\NewRelicInteractor` | This interactor communicates with NewRelic. It is the one decorator that actually does some work. | +| `Ekino\NewRelicBundle\NewRelic\BlackholeInteractor` | This interactor does nothing. | +| `auto` | This value will check if the NewRelic PHP extension is installed when you build your container. | + +Note that if you set `ekino_new_relic.enabled: false` you will always use the `BlackholeInteractor` no matter what value +used for `ekino_new_relic.interactor`. + + ## Flow of the Request 1. A request comes in and the first thing we do is to `setApplicationName` so that we use the correct license key and name. diff --git a/Tests/BundleInitializationTest.php b/Tests/BundleInitializationTest.php index 37bc038..fb16e95 100644 --- a/Tests/BundleInitializationTest.php +++ b/Tests/BundleInitializationTest.php @@ -14,6 +14,7 @@ namespace Ekino\NewRelicBundle\Tests; use Ekino\NewRelicBundle\EkinoNewRelicBundle; +use Ekino\NewRelicBundle\NewRelic\AdaptiveInteractor; use Ekino\NewRelicBundle\NewRelic\BlackholeInteractor; use Ekino\NewRelicBundle\NewRelic\NewRelicInteractor; use Ekino\NewRelicBundle\NewRelic\NewRelicInteractorInterface; @@ -49,7 +50,7 @@ public function testInitBundle() $container = $this->getContainer(); $services = [ - NewRelicInteractorInterface::class => BlackholeInteractor::class, + NewRelicInteractorInterface::class => AdaptiveInteractor::class, BlackholeInteractor::class, NewRelicInteractor::class, ];