diff --git a/CHANGES b/CHANGES index ec9d81f..df11509 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ -1.3.1 (TBD): -- Support finer granularity timeouts and milliseconds granularity +1.4.0 (TBD): +- Add support for a custom tracer for client methods. +- Support finer granularity timeouts and milliseconds granularity. 1.3.0 (Nov 10, 2023): - Added in-memory evaluation cache for the duration of a request. diff --git a/examples/tracer.php b/examples/tracer.php index fc0cd2c..877eda7 100644 --- a/examples/tracer.php +++ b/examples/tracer.php @@ -3,24 +3,24 @@ require_once '../vendor/autoload.php'; use \SplitIO\ThinSdk\Factory; -use \SplitIO\ThinSdk\Utils\Tracer; -use \SplitIO\ThinSdk\Utils\TracerHook; +use \SplitIO\ThinSdk\Utils\Tracing\Tracer; +use \SplitIO\ThinSdk\Utils\Tracing\TracerHook; class CustomTracer implements TracerHook { private $events = []; - public function on(int $method, int $event, ?array $arguments) + public function on(array $event) { // assume we only care about getTreatment() calls... - if ($method != Tracer::METHOD_GET_TREATMENT) { + if ($event['method'] != Tracer::METHOD_GET_TREATMENT) { return; } - switch ($event) { + switch ($event['event']) { case Tracer::EVENT_START: - array_push($this->events, "start (" . json_encode($arguments) . ") -- " . microtime(true)); + array_push($this->events, "start (" . json_encode($event['arguments']) . ") -- " . microtime(true)); break; case Tracer::EVENT_RPC_START: array_push($this->events, "about to send rpc -- " . microtime(true)); @@ -54,7 +54,7 @@ public function getEvents(): array 'level' => \Psr\Log\LogLevel::INFO, ], 'utils' => [ - '__tracer' => [ + 'tracer' => [ 'hook' => $ct, 'forwardArgs' => true, ] diff --git a/src/Config/Utils.php b/src/Config/Utils.php index d575830..89be7e0 100644 --- a/src/Config/Utils.php +++ b/src/Config/Utils.php @@ -39,7 +39,7 @@ public static function fromArray(array $config): Utils return new Utils( $config['impressionListener'] ?? $d->impressionListener(), EvaluationCache::fromArray($config['evaluationCache'] ?? []), - Tracer::fromArray($config['__tracer'] ?? []), + Tracer::fromArray($config['tracer'] ?? []), ); } diff --git a/tests/Config/UtilsTest.php b/tests/Config/UtilsTest.php index b033d6a..674cfd1 100644 --- a/tests/Config/UtilsTest.php +++ b/tests/Config/UtilsTest.php @@ -35,7 +35,7 @@ public function testConfigParsing() 'maxSize' => 1234, 'customHash' => $ihMock, ], - '__tracer' => [ + 'tracer' => [ 'hook' => $tMock, 'forwardArgs' => true, ],