File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44namespace Jaeger \Client ;
55
6+ use Jaeger \Process \CliProcess ;
67use Jaeger \Process \FpmProcess ;
78use Jaeger \Process \InternalServerProcess ;
8- use Jaeger \Thrift \Agent \AgentIf as AgentInterface ;
9- use Jaeger \Process \CliProcess ;
109use Jaeger \Span \Batch \SpanBatch ;
1110use Jaeger \Span \SpanInterface ;
11+ use Jaeger \Thrift \Agent \AgentIf as AgentInterface ;
1212
1313class ThriftClient implements ClientInterface
1414{
15+ const MAX_BATCH_SIZE = 100 ;
16+
1517 private $ serviceName ;
1618
1719 private $ agent ;
@@ -28,10 +30,10 @@ public function add(SpanInterface $span): ClientInterface
2830 {
2931 $ this ->spans [] = $ span ;
3032
31- return $ this ;
33+ return $ this -> flush () ;
3234 }
3335
34- public function getSpans () : array
36+ public function getSpans (): array
3537 {
3638 return $ this ->spans ;
3739 }
@@ -49,7 +51,9 @@ public function flush(): ClientInterface
4951 $ process = new FpmProcess ($ this ->serviceName );
5052 break ;
5153 }
52- $ this ->agent ->emitBatch (new SpanBatch ($ process , $ this ->spans ));
54+ foreach (array_chunk ($ this ->spans , self ::MAX_BATCH_SIZE ) as $ batch ) {
55+ $ this ->agent ->emitBatch (new SpanBatch ($ process , $ batch ));
56+ }
5357 $ this ->spans = [];
5458
5559 return $ this ;
You can’t perform that action at this time.
0 commit comments