diff --git a/src/DDTrace/Integrations/Guzzle/v5/GuzzleIntegration.php b/src/DDTrace/Integrations/Guzzle/v5/GuzzleIntegration.php index baaaa10bc5b..9a05bf54894 100644 --- a/src/DDTrace/Integrations/Guzzle/v5/GuzzleIntegration.php +++ b/src/DDTrace/Integrations/Guzzle/v5/GuzzleIntegration.php @@ -11,9 +11,8 @@ class GuzzleIntegration extends Integration { const CLASS_NAME = 'GuzzleHttp\Client'; - public static function load() + protected static function loadIntegration() { - parent::load(); self::traceMethod('send', function (Span $span, array $args) { $span->setTag('http.method', $args[0]->getMethod()); }); diff --git a/src/DDTrace/Integrations/Integration.php b/src/DDTrace/Integrations/Integration.php index 8d5825b33ef..c5649b5df1d 100644 --- a/src/DDTrace/Integrations/Integration.php +++ b/src/DDTrace/Integrations/Integration.php @@ -14,14 +14,18 @@ public static function load() { if (!extension_loaded('ddtrace')) { trigger_error('The ddtrace extension is required to trace ' . static::CLASS_NAME, E_USER_WARNING); - return; + return false; } if (!class_exists(static::CLASS_NAME)) { trigger_error(static::CLASS_NAME . ' is not loaded and cannot be traced', E_USER_WARNING); - return; + return false; } + static::loadIntegration(); + return true; } + abstract protected static function loadIntegration(); + /** * @param string $method * @param \Closure $spanMutator diff --git a/tests/Integration/Integrations/Guzzle/v5/GuzzleIntegrationTest.php b/tests/Integration/Integrations/Guzzle/v5/GuzzleIntegrationTest.php index a4b80d0f2f8..ecad25aec55 100644 --- a/tests/Integration/Integrations/Guzzle/v5/GuzzleIntegrationTest.php +++ b/tests/Integration/Integrations/Guzzle/v5/GuzzleIntegrationTest.php @@ -16,7 +16,9 @@ final class GuzzleIntegrationTest extends IntegrationTestCase public static function setUpBeforeClass() { - GuzzleIntegration::load(); + if(!GuzzleIntegration::load()) { + self::markTestSkipped('Guzzle required to run tests.'); + } } protected function setUp()