Skip to content

Commit d5d1d5d

Browse files
committed
Added control over batch size
1 parent 621d208 commit d5d1d5d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Client/ThriftClient.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@
1212

1313
class ThriftClient implements ClientInterface
1414
{
15-
const MAX_BATCH_SIZE = 32;
15+
public const MAX_BATCH_SIZE = 32;
1616

1717
private $serviceName;
1818

1919
private $agent;
2020

21+
private $batch;
22+
2123
private $spans = [];
2224

23-
public function __construct(string $serviceName, AgentInterface $agent)
25+
public function __construct(string $serviceName, AgentInterface $agent, int $batch = self::MAX_BATCH_SIZE)
2426
{
2527
$this->serviceName = $serviceName;
2628
$this->agent = $agent;
29+
$this->batch = $batch;
2730
}
2831

2932
public function add(SpanInterface $span): ClientInterface
@@ -51,7 +54,7 @@ public function flush(): ClientInterface
5154
$process = new FpmProcess($this->serviceName);
5255
break;
5356
}
54-
foreach (array_chunk($this->spans, self::MAX_BATCH_SIZE) as $batch) {
57+
foreach (array_chunk($this->spans, $this->batch) as $batch) {
5558
$this->agent->emitBatch(new SpanBatch($process, $batch));
5659
}
5760
$this->spans = [];

0 commit comments

Comments
 (0)