From f52ecf09bf7cee26885eb4a2f12aa2ac9d2aa005 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Thu, 19 Sep 2019 13:03:09 +0100 Subject: [PATCH 1/4] Updated composer.json as we do NOT provide psr/log implementation --- composer.json | 4 -- composer.lock | 114 +++++++++++++++++++++++------------------------ phpunit.xml.dist | 2 +- 3 files changed, 57 insertions(+), 63 deletions(-) diff --git a/composer.json b/composer.json index f8c29c5f..bbe59739 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "vimeo/psalm": "^3.4" }, "suggest": { - "ext-xdebug": "Required for processing of request headers", "ext-scoutapm": "Recommended for additional recording capability of IO-bound PHP internal functions" }, "autoload": { @@ -46,8 +45,5 @@ }, "preferred-install": "dist", "sort-packages": true - }, - "provide": { - "psr/log-implementation": "1.0.0" } } diff --git a/composer.lock b/composer.lock index 970855e5..e62d7e33 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fdca33732dd56bfc62f395cc59df48bb", + "content-hash": "d95ca739c9986f6dabf5f1769e4c36b2", "packages": [ { "name": "ocramius/package-versions", @@ -958,16 +958,16 @@ }, { "name": "felixfbecker/advanced-json-rpc", - "version": "v3.0.3", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/felixfbecker/php-advanced-json-rpc.git", - "reference": "241c470695366e7b83672be04ea0e64d8085a551" + "reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/241c470695366e7b83672be04ea0e64d8085a551", - "reference": "241c470695366e7b83672be04ea0e64d8085a551", + "url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/23366dd0cab0a0f3fd3016bf3c0b36dec74348e7", + "reference": "23366dd0cab0a0f3fd3016bf3c0b36dec74348e7", "shasum": "" }, "require": { @@ -995,7 +995,7 @@ } ], "description": "A more advanced JSONRPC implementation", - "time": "2018-09-10T08:58:41+00:00" + "time": "2019-09-12T22:41:08+00:00" }, { "name": "felixfbecker/language-server-protocol", @@ -1476,35 +1476,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1526,30 +1524,30 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "4.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", "phpunit/phpunit": "^6.4" }, @@ -1577,41 +1575,40 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2019-09-12T14:27:41+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1624,7 +1621,8 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", @@ -1941,16 +1939,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e899757bb3df5ff6e95089132f32cd59aac2220a", - "reference": "e899757bb3df5ff6e95089132f32cd59aac2220a", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { @@ -1986,20 +1984,20 @@ "keywords": [ "tokenizer" ], - "time": "2019-07-25T05:29:42+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "7.5.15", + "version": "7.5.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d79c053d972856b8b941bb233e39dc521a5093f0" + "reference": "316afa6888d2562e04aeb67ea7f2017a0eb41661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d79c053d972856b8b941bb233e39dc521a5093f0", - "reference": "d79c053d972856b8b941bb233e39dc521a5093f0", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/316afa6888d2562e04aeb67ea7f2017a0eb41661", + "reference": "316afa6888d2562e04aeb67ea7f2017a0eb41661", "shasum": "" }, "require": { @@ -2070,7 +2068,7 @@ "testing", "xunit" ], - "time": "2019-08-21T07:05:16+00:00" + "time": "2019-09-14T09:08:39+00:00" }, { "name": "react/event-loop", @@ -2380,16 +2378,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.1", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "06a9a5947f47b3029d76118eb5c22802e5869687" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/06a9a5947f47b3029d76118eb5c22802e5869687", - "reference": "06a9a5947f47b3029d76118eb5c22802e5869687", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -2443,7 +2441,7 @@ "export", "exporter" ], - "time": "2019-08-11T12:43:14+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", @@ -3258,16 +3256,16 @@ }, { "name": "vimeo/psalm", - "version": "3.4.12", + "version": "3.5.1", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "86e5e50c1bb492045e70f2ebe1da3cad06e4e9b2" + "reference": "deb36e8b273d4b25601f1991482a69d412e3169f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/86e5e50c1bb492045e70f2ebe1da3cad06e4e9b2", - "reference": "86e5e50c1bb492045e70f2ebe1da3cad06e4e9b2", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/deb36e8b273d4b25601f1991482a69d412e3169f", + "reference": "deb36e8b273d4b25601f1991482a69d412e3169f", "shasum": "" }, "require": { @@ -3341,7 +3339,7 @@ "inspection", "php" ], - "time": "2019-08-20T18:26:32+00:00" + "time": "2019-09-10T01:28:56+00:00" }, { "name": "webmozart/glob", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4dcfaca7..b7353f45 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,7 +12,7 @@ > - ./tests/ + ./tests/Unit ./tests/Integration From 8374c810282e1ffd544a87829ba70e085723ea8a Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Thu, 19 Sep 2019 13:04:50 +0100 Subject: [PATCH 2/4] Added an interface for Agent to make client consumption more stable --- src/Agent.php | 3 +- src/ScoutApmAgent.php | 76 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 src/ScoutApmAgent.php diff --git a/src/Agent.php b/src/Agent.php index ab6a538e..057f6740 100644 --- a/src/Agent.php +++ b/src/Agent.php @@ -26,8 +26,7 @@ use Scoutapm\Extension\ExtentionCapabilities; use Scoutapm\Extension\PotentiallyAvailableExtensionCapabilities; -// @todo needs interface -final class Agent +final class Agent implements ScoutApmAgent { /** @var Config */ private $config; diff --git a/src/ScoutApmAgent.php b/src/ScoutApmAgent.php new file mode 100644 index 00000000..982ad2df --- /dev/null +++ b/src/ScoutApmAgent.php @@ -0,0 +1,76 @@ + Date: Thu, 19 Sep 2019 13:09:08 +0100 Subject: [PATCH 3/4] Collapse docblocks inherited from interface now --- src/Agent.php | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/Agent.php b/src/Agent.php index 057f6740..7e5bb073 100644 --- a/src/Agent.php +++ b/src/Agent.php @@ -7,7 +7,6 @@ use Closure; use DateTimeImmutable; use DateTimeZone; -use Exception; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; use Scoutapm\Config\IgnoredEndpoints; @@ -133,25 +132,13 @@ public function connect() : void } } - /** - * Returns true/false on if the agent should attempt to start and collect data. - */ + /** {@inheritDoc} */ public function enabled() : bool { return $this->config->get('monitor'); } - /** - * Starts a fromRequest span on the current request. - * - * NOTE: Do not call stop on the span itself, use the stopSpan() function - * here to ensure the whole system knows its stopped - * - * @param string $operation The "name" of the span, something like "Controller/User" or "SQL/Query" - * @param ?float $overrideTimestamp If you need to set the start time to something specific - * - * @throws Exception - */ + /** {@inheritDoc} */ public function startSpan(string $operation, ?float $overrideTimestamp = null) : Span { if ($this->request === null) { @@ -189,7 +176,7 @@ private function addSpansFromExtension() : void } } - /** @return mixed */ + /** {@inheritDoc} */ public function instrument(string $type, string $name, Closure $block) { $span = $this->startSpan($type . '/' . $name); @@ -201,13 +188,13 @@ public function instrument(string $type, string $name, Closure $block) } } - /** @return mixed */ + /** {@inheritDoc} */ public function webTransaction(string $name, Closure $block) { return $this->instrument('Controller', $name, $block); } - /** @return mixed */ + /** {@inheritDoc} */ public function backgroundTransaction(string $name, Closure $block) { return $this->instrument('Job', $name, $block); @@ -227,31 +214,20 @@ public function tagRequest(string $tag, string $value) : void $this->request->tag($tag, $value); } - /** - * Check if a given URL was configured as ignored. - * Does not alter the running request. If you wish to abort tracing of this - * request, use ignore() - */ + /** {@inheritDoc} */ public function ignored(string $path) : bool { return $this->ignoredEndpoints->ignored($path); } - /** - * Mark the running request as ignored. Triggers optimizations in various - * tracing and tagging methods to turn them into NOOPs - */ + /** {@inheritDoc} */ public function ignore() : void { $this->request = null; $this->isIgnored = true; } - /** - * Returns true only if the request was sent onward to the core agent. False otherwise. - * - * @throws Exception - */ + /** {@inheritDoc} */ public function send() : bool { // Don't send if the agent is not enabled. @@ -308,7 +284,7 @@ public function send() : bool } /** - * You probably don't need this, it's useful in testing + * {@inheritDoc} * * @internal * @deprecated From ee3a95a98985271dc813ec1d07668c7491ff6bbf Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Thu, 19 Sep 2019 13:12:52 +0100 Subject: [PATCH 4/4] Unset SCOUT_API_VERSION since global state affects other tests --- tests/Unit/ConfigTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Unit/ConfigTest.php b/tests/Unit/ConfigTest.php index 16315498..d3e2b93a 100644 --- a/tests/Unit/ConfigTest.php +++ b/tests/Unit/ConfigTest.php @@ -38,6 +38,8 @@ public function testEnvOverridesAll() : void putenv('SCOUT_API_VERSION=viaenvvar'); self::assertSame('viaenvvar', $config->get('api_version')); + + putenv('SCOUT_API_VERSION'); } public function testBooleanCoercionOfMonitor() : void