@@ -878,92 +878,95 @@ public function testDistributedTracing()
878
878
{
879
879
// Note: This test is extremely flaky, locally at least. It will eventually pass with some tries...
880
880
// Reason: We may parse the traces from dumped data BEFORE the traces are flushed.
881
-
882
- self ::putEnv ('DD_TRACE_DEBUG_PRNG_SEED=42 ' ); // Not necessary, but makes it easier to debug locally
883
-
884
- $ sendTraces = $ this ->inCli (
885
- __DIR__ . '/../scripts/send.php ' ,
886
- [
887
- 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
888
- 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'true ' ,
889
- 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
890
- ],
891
- [],
892
- self ::$ autoloadPath
893
- );
894
-
895
- list ($ receiveTraces , $ output ) = $ this ->inCli (
896
- __DIR__ . '/../scripts/receive.php ' ,
897
- [
898
- 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
899
- 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'false ' ,
900
- 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
901
- ],
902
- [],
903
- self ::$ autoloadPath ,
904
- true
905
- );
906
-
907
- // Assess that user headers weren't lost
908
- $ this ->assertSame ("" , trim (preg_replace ("(.*\[ddtrace].*) " , "" , $ output )));
909
-
910
- $ sendTraces = $ sendTraces [0 ][0 ]; // There is a root span
911
- // Spans: send.php -> basic_publish -> queue_declare -> connect
912
- $ basicPublishSpan = $ sendTraces [1 ];
913
-
914
- foreach ($ receiveTraces as $ receiveTrace ) {
915
- // Spans: connect -> queue_declare -> basic_consume & basic_consume_ok -> basic_deliver
916
- if ($ receiveTrace [0 ]["name " ] == "amqp.basic.deliver " ) {
917
- $ basicDeliverSpan = $ receiveTrace [0 ];
918
- break ;
881
+ $ this ->retryTest (function () {
882
+ self ::putEnv ('DD_TRACE_DEBUG_PRNG_SEED=42 ' ); // Not necessary, but makes it easier to debug locally
883
+
884
+ $ sendTraces = $ this ->inCli (
885
+ __DIR__ . '/../scripts/send.php ' ,
886
+ [
887
+ 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
888
+ 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'true ' ,
889
+ 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
890
+ ],
891
+ [],
892
+ self ::$ autoloadPath
893
+ );
894
+
895
+ list ($ receiveTraces , $ output ) = $ this ->inCli (
896
+ __DIR__ . '/../scripts/receive.php ' ,
897
+ [
898
+ 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
899
+ 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'false ' ,
900
+ 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
901
+ ],
902
+ [],
903
+ self ::$ autoloadPath ,
904
+ true
905
+ );
906
+
907
+ // Assess that user headers weren't lost
908
+ $ this ->assertSame ("" , trim (preg_replace ("(.*\[ddtrace].*) " , "" , $ output )));
909
+
910
+ $ sendTraces = $ sendTraces [0 ][0 ]; // There is a root span
911
+ // Spans: send.php -> basic_publish -> queue_declare -> connect
912
+ $ basicPublishSpan = $ sendTraces [1 ];
913
+
914
+ foreach ($ receiveTraces as $ receiveTrace ) {
915
+ // Spans: connect -> queue_declare -> basic_consume & basic_consume_ok -> basic_deliver
916
+ if ($ receiveTrace [0 ]["name " ] == "amqp.basic.deliver " ) {
917
+ $ basicDeliverSpan = $ receiveTrace [0 ];
918
+ break ;
919
+ }
919
920
}
920
- }
921
921
922
- $ this ->assertSame ($ basicPublishSpan ['trace_id ' ], $ basicDeliverSpan ['trace_id ' ]);
923
- $ this ->assertSame ($ basicPublishSpan ['span_id ' ], $ basicDeliverSpan ['parent_id ' ]);
922
+ $ this ->assertSame ($ basicPublishSpan ['trace_id ' ], $ basicDeliverSpan ['trace_id ' ]);
923
+ $ this ->assertSame ($ basicPublishSpan ['span_id ' ], $ basicDeliverSpan ['parent_id ' ]);
924
+ });
924
925
}
925
926
926
927
public function testDistributedTracingIsNotPropagatedIfDisabled ()
927
928
{
928
929
self ::putEnv ('DD_TRACE_DEBUG_PRNG_SEED=42 ' ); // Not necessary, but makes it easier to debug locally
929
930
930
- $ sendTraces = $ this ->inCli (
931
- __DIR__ . '/../scripts/send.php ' ,
932
- [
933
- 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
934
- 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'true ' ,
935
- 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
936
- 'DD_DISTRIBUTED_TRACING ' => 'false '
937
- ],
938
- [],
939
- self ::$ autoloadPath
940
- );
941
-
942
- list ($ receiveTraces , $ output ) = $ this ->inCli (
943
- __DIR__ . '/../scripts/receive.php ' ,
944
- [
945
- 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
946
- 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'false ' ,
947
- 'DD_TRACE_CLI_ENABLED ' => 'true '
948
- ],
949
- [],
950
- self ::$ autoloadPath ,
951
- true
952
- );
953
-
954
- // Assess that user headers weren't lost
955
- $ this ->assertSame ("" , trim (preg_replace ("(.*\[ddtrace].*) " , "" , $ output )));
956
-
957
- $ sendTraces = $ sendTraces [0 ][0 ]; // There is a root span
958
- // Spans: send.php -> basic_publish -> queue_declare -> connect
959
- $ basicPublishSpan = $ sendTraces [1 ];
960
-
961
- $ receiveTraces = $ receiveTraces [3 ]; // There isn't a root span
962
- // Spans: connect -> queue_declare -> basic_consume & basic_consume_ok -> basic_deliver
963
- $ basicDeliverSpan = $ receiveTraces [0 ];
964
-
965
- $ this ->assertNotSame ($ basicPublishSpan ['trace_id ' ], $ basicDeliverSpan ['trace_id ' ]);
966
- $ this ->assertArrayNotHasKey ('parent_id ' , $ basicDeliverSpan );
931
+ $ this ->retryTest (function () {
932
+ $ sendTraces = $ this ->inCli (
933
+ __DIR__ . '/../scripts/send.php ' ,
934
+ [
935
+ 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
936
+ 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'true ' ,
937
+ 'DD_TRACE_CLI_ENABLED ' => 'true ' ,
938
+ 'DD_DISTRIBUTED_TRACING ' => 'false '
939
+ ],
940
+ [],
941
+ self ::$ autoloadPath
942
+ );
943
+
944
+ list ($ receiveTraces , $ output ) = $ this ->inCli (
945
+ __DIR__ . '/../scripts/receive.php ' ,
946
+ [
947
+ 'DD_TRACE_AUTO_FLUSH_ENABLED ' => 'true ' ,
948
+ 'DD_TRACE_GENERATE_ROOT_SPAN ' => 'false ' ,
949
+ 'DD_TRACE_CLI_ENABLED ' => 'true '
950
+ ],
951
+ [],
952
+ self ::$ autoloadPath ,
953
+ true
954
+ );
955
+
956
+ // Assess that user headers weren't lost
957
+ $ this ->assertSame ("" , trim (preg_replace ("(.*\[ddtrace].*) " , "" , $ output )));
958
+
959
+ $ sendTraces = $ sendTraces [0 ][0 ]; // There is a root span
960
+ // Spans: send.php -> basic_publish -> queue_declare -> connect
961
+ $ basicPublishSpan = $ sendTraces [1 ];
962
+
963
+ $ receiveTraces = $ receiveTraces [3 ]; // There isn't a root span
964
+ // Spans: connect -> queue_declare -> basic_consume & basic_consume_ok -> basic_deliver
965
+ $ basicDeliverSpan = $ receiveTraces [0 ];
966
+
967
+ $ this ->assertNotSame ($ basicPublishSpan ['trace_id ' ], $ basicDeliverSpan ['trace_id ' ]);
968
+ $ this ->assertArrayNotHasKey ('parent_id ' , $ basicDeliverSpan );
969
+ });
967
970
}
968
971
969
972
public function testBatchedPublishing ()
0 commit comments