File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313class 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 = [];
You can’t perform that action at this time.
0 commit comments