Skip to content

Commit b55f354

Browse files
committed
tracer cleanup
1 parent afb6991 commit b55f354

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

CHANGES

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
1.3.1 (TBD):
2-
- Support finer granularity timeouts and milliseconds granularity
1+
1.4.0 (TBD):
2+
- Add support for a custom tracer for client methods.
3+
- Support finer granularity timeouts and milliseconds granularity.
34

45
1.3.0 (Nov 10, 2023):
56
- Added in-memory evaluation cache for the duration of a request.

examples/tracer.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
require_once '../vendor/autoload.php';
44

55
use \SplitIO\ThinSdk\Factory;
6-
use \SplitIO\ThinSdk\Utils\Tracer;
7-
use \SplitIO\ThinSdk\Utils\TracerHook;
6+
use \SplitIO\ThinSdk\Utils\Tracing\Tracer;
7+
use \SplitIO\ThinSdk\Utils\Tracing\TracerHook;
88

99
class CustomTracer implements TracerHook
1010
{
1111

1212
private $events = [];
1313

14-
public function on(int $method, int $event, ?array $arguments)
14+
public function on(array $event)
1515
{
1616
// assume we only care about getTreatment() calls...
17-
if ($method != Tracer::METHOD_GET_TREATMENT) {
17+
if ($event['method'] != Tracer::METHOD_GET_TREATMENT) {
1818
return;
1919
}
2020

21-
switch ($event) {
21+
switch ($event['event']) {
2222
case Tracer::EVENT_START:
23-
array_push($this->events, "start (" . json_encode($arguments) . ") -- " . microtime(true));
23+
array_push($this->events, "start (" . json_encode($event['arguments']) . ") -- " . microtime(true));
2424
break;
2525
case Tracer::EVENT_RPC_START:
2626
array_push($this->events, "about to send rpc -- " . microtime(true));
@@ -54,7 +54,7 @@ public function getEvents(): array
5454
'level' => \Psr\Log\LogLevel::INFO,
5555
],
5656
'utils' => [
57-
'__tracer' => [
57+
'tracer' => [
5858
'hook' => $ct,
5959
'forwardArgs' => true,
6060
]

src/Config/Utils.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function fromArray(array $config): Utils
3939
return new Utils(
4040
$config['impressionListener'] ?? $d->impressionListener(),
4141
EvaluationCache::fromArray($config['evaluationCache'] ?? []),
42-
Tracer::fromArray($config['__tracer'] ?? []),
42+
Tracer::fromArray($config['tracer'] ?? []),
4343
);
4444
}
4545

tests/Config/UtilsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testConfigParsing()
3535
'maxSize' => 1234,
3636
'customHash' => $ihMock,
3737
],
38-
'__tracer' => [
38+
'tracer' => [
3939
'hook' => $tMock,
4040
'forwardArgs' => true,
4141
],

0 commit comments

Comments
 (0)