@@ -245,6 +245,7 @@ mod tests {
245245 use crate :: plugins:: telemetry:: config:: Exporters ;
246246 use crate :: plugins:: telemetry:: config:: Instrumentation ;
247247 use crate :: plugins:: telemetry:: config:: Metrics ;
248+ use crate :: plugins:: telemetry:: config:: Propagation ;
248249 use crate :: plugins:: telemetry:: config:: Tracing ;
249250
250251 fn create_default_config ( ) -> Conf {
@@ -626,4 +627,273 @@ mod tests {
626627 "Tracer provider should reload when span limits change"
627628 ) ;
628629 }
630+
631+ #[ tokio:: test( flavor = "multi_thread" ) ]
632+ async fn test_datadog_propagation_only_passes ( ) {
633+ let mut config = create_config_with_apollo_enabled ( ) ;
634+ config. exporters . tracing . propagation = Propagation {
635+ datadog : Some ( true ) ,
636+ ..Default :: default ( )
637+ } ;
638+
639+ let builder = Builder :: new ( & None , & config) ;
640+ assert ! ( builder. build( ) . is_ok( ) ) ;
641+ }
642+
643+ #[ tokio:: test( flavor = "multi_thread" ) ]
644+ async fn test_datadog_with_baggage_propagation_passes ( ) {
645+ let mut config = create_config_with_apollo_enabled ( ) ;
646+ config. exporters . tracing . propagation = Propagation {
647+ datadog : Some ( true ) ,
648+ baggage : true ,
649+ ..Default :: default ( )
650+ } ;
651+
652+ let builder = Builder :: new ( & None , & config) ;
653+ assert ! ( builder. build( ) . is_ok( ) ) ;
654+ }
655+
656+ #[ tokio:: test( flavor = "multi_thread" ) ]
657+ async fn test_jaeger_propagation_only_passes ( ) {
658+ let mut config = create_config_with_apollo_enabled ( ) ;
659+ config. exporters . tracing . propagation = Propagation {
660+ jaeger : true ,
661+ ..Default :: default ( )
662+ } ;
663+
664+ let builder = Builder :: new ( & None , & config) ;
665+ assert ! ( builder. build( ) . is_ok( ) ) ;
666+ }
667+
668+ #[ tokio:: test( flavor = "multi_thread" ) ]
669+ async fn test_datadog_with_jaeger_propagation_fails ( ) {
670+ use crate :: test_harness:: tracing_test;
671+ let _guard = tracing_test:: dispatcher_guard ( ) ;
672+ let mut config = create_config_with_apollo_enabled ( ) ;
673+ config. exporters . tracing . propagation = Propagation {
674+ datadog : Some ( true ) ,
675+ jaeger : true ,
676+ ..Default :: default ( )
677+ } ;
678+
679+ let builder = Builder :: new ( & None , & config) ;
680+ assert ! ( builder. build( ) . is_ok( ) ) ;
681+ assert ! ( tracing_test:: logs_contain(
682+ "datadog propagation should not be used with any other propagator except for baggage to avoid trace id conflicts" ,
683+ ) ) ;
684+ }
685+
686+ #[ tokio:: test( flavor = "multi_thread" ) ]
687+ async fn test_datadog_with_trace_context_propagation_fails ( ) {
688+ use crate :: test_harness:: tracing_test;
689+ let _guard = tracing_test:: dispatcher_guard ( ) ;
690+ let mut config = create_config_with_apollo_enabled ( ) ;
691+ config. exporters . tracing . propagation = Propagation {
692+ datadog : Some ( true ) ,
693+ trace_context : true ,
694+ ..Default :: default ( )
695+ } ;
696+
697+ let builder = Builder :: new ( & None , & config) ;
698+ assert ! ( builder. build( ) . is_ok( ) ) ;
699+ assert ! ( tracing_test:: logs_contain(
700+ "datadog propagation should not be used with any other propagator except for baggage to avoid trace id conflicts" ,
701+ ) ) ;
702+ }
703+
704+ #[ tokio:: test( flavor = "multi_thread" ) ]
705+ async fn test_datadog_with_zipkin_propagation_fails ( ) {
706+ use crate :: test_harness:: tracing_test;
707+ let _guard = tracing_test:: dispatcher_guard ( ) ;
708+ let mut config = create_config_with_apollo_enabled ( ) ;
709+ config. exporters . tracing . propagation = Propagation {
710+ datadog : Some ( true ) ,
711+ zipkin : true ,
712+ ..Default :: default ( )
713+ } ;
714+
715+ let builder = Builder :: new ( & None , & config) ;
716+ assert ! ( builder. build( ) . is_ok( ) ) ;
717+ assert ! ( tracing_test:: logs_contain(
718+ "datadog propagation should not be used with any other propagator except for baggage to avoid trace id conflicts" ,
719+ ) ) ;
720+ }
721+
722+ #[ tokio:: test( flavor = "multi_thread" ) ]
723+ async fn test_datadog_with_aws_xray_propagation_fails ( ) {
724+ use crate :: test_harness:: tracing_test;
725+ let _guard = tracing_test:: dispatcher_guard ( ) ;
726+ let mut config = create_config_with_apollo_enabled ( ) ;
727+ config. exporters . tracing . propagation = Propagation {
728+ datadog : Some ( true ) ,
729+ aws_xray : true ,
730+ ..Default :: default ( )
731+ } ;
732+
733+ let builder = Builder :: new ( & None , & config) ;
734+ assert ! ( builder. build( ) . is_ok( ) ) ;
735+ assert ! ( tracing_test:: logs_contain(
736+ "datadog propagation should not be used with any other propagator except for baggage to avoid trace id conflicts" ,
737+ ) ) ;
738+ }
739+
740+ #[ tokio:: test( flavor = "multi_thread" ) ]
741+ async fn test_datadog_exporter_enabled_with_datadog_propagation_only_passes ( ) {
742+ use crate :: test_harness:: tracing_test;
743+ let _guard = tracing_test:: dispatcher_guard ( ) ;
744+ let mut config = create_config_with_apollo_enabled ( ) ;
745+ config. exporters . tracing . datadog . enabled = true ;
746+ config. exporters . tracing . propagation = Propagation {
747+ datadog : Some ( true ) ,
748+ ..Default :: default ( )
749+ } ;
750+
751+ let builder = Builder :: new ( & None , & config) ;
752+ assert ! ( builder. build( ) . is_ok( ) ) ;
753+ }
754+
755+ #[ tokio:: test( flavor = "multi_thread" ) ]
756+ async fn test_datadog_exporter_enabled_with_datadog_baggage_propagation_passes ( ) {
757+ use crate :: test_harness:: tracing_test;
758+ let _guard = tracing_test:: dispatcher_guard ( ) ;
759+ let mut config = create_config_with_apollo_enabled ( ) ;
760+ config. exporters . tracing . datadog . enabled = true ;
761+ config. exporters . tracing . propagation = Propagation {
762+ datadog : Some ( true ) ,
763+ baggage : true ,
764+ ..Default :: default ( )
765+ } ;
766+
767+ let builder = Builder :: new ( & None , & config) ;
768+ assert ! ( builder. build( ) . is_ok( ) ) ;
769+ }
770+
771+ #[ tokio:: test( flavor = "multi_thread" ) ]
772+ async fn test_datadog_exporter_enabled_with_jaeger_propagation_only_fails ( ) {
773+ use crate :: test_harness:: tracing_test;
774+ let _guard = tracing_test:: dispatcher_guard ( ) ;
775+ let mut config = create_config_with_apollo_enabled ( ) ;
776+ config. exporters . tracing . datadog . enabled = true ;
777+ config. exporters . tracing . propagation = Propagation {
778+ jaeger : true ,
779+ ..Default :: default ( )
780+ } ;
781+
782+ let builder = Builder :: new ( & None , & config) ;
783+ assert ! ( builder. build( ) . is_ok( ) ) ;
784+ assert ! ( tracing_test:: logs_contain(
785+ "datadog propagation should be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled to avoid trace id conflicts" ,
786+ ) ) ;
787+ }
788+
789+ #[ tokio:: test( flavor = "multi_thread" ) ]
790+ async fn test_datadog_exporter_enabled_with_datadog_jaeger_propagation_fails ( ) {
791+ use crate :: test_harness:: tracing_test;
792+ let _guard = tracing_test:: dispatcher_guard ( ) ;
793+ let mut config = create_config_with_apollo_enabled ( ) ;
794+ config. exporters . tracing . datadog . enabled = true ;
795+ config. exporters . tracing . propagation = Propagation {
796+ datadog : Some ( true ) ,
797+ jaeger : true ,
798+ ..Default :: default ( )
799+ } ;
800+
801+ let builder = Builder :: new ( & None , & config) ;
802+ assert ! ( builder. build( ) . is_ok( ) ) ;
803+ assert ! ( tracing_test:: logs_contain(
804+ "if the datadog exporter is enabled and any other propagator except for baggage is enabled, the datadog propagator should be disabled to avoid trace id conflicts" ,
805+ ) ) ;
806+ }
807+
808+ #[ tokio:: test( flavor = "multi_thread" ) ]
809+ async fn test_datadog_exporter_enabled_with_datadog_trace_context_propagation_fails ( ) {
810+ use crate :: test_harness:: tracing_test;
811+ let _guard = tracing_test:: dispatcher_guard ( ) ;
812+ let mut config = create_config_with_apollo_enabled ( ) ;
813+ config. exporters . tracing . datadog . enabled = true ;
814+ config. exporters . tracing . propagation = Propagation {
815+ datadog : Some ( true ) ,
816+ trace_context : true ,
817+ ..Default :: default ( )
818+ } ;
819+
820+ let builder = Builder :: new ( & None , & config) ;
821+ assert ! ( builder. build( ) . is_ok( ) ) ;
822+ assert ! ( tracing_test:: logs_contain(
823+ "if the datadog exporter is enabled and any other propagator except for baggage is enabled, the datadog propagator should be disabled to avoid trace id conflicts" ,
824+ ) ) ;
825+ }
826+
827+ #[ tokio:: test( flavor = "multi_thread" ) ]
828+ async fn test_datadog_exporter_enabled_with_datadog_zipkin_propagation_fails ( ) {
829+ use crate :: test_harness:: tracing_test;
830+ let _guard = tracing_test:: dispatcher_guard ( ) ;
831+ let mut config = create_config_with_apollo_enabled ( ) ;
832+ config. exporters . tracing . datadog . enabled = true ;
833+ config. exporters . tracing . propagation = Propagation {
834+ datadog : Some ( true ) ,
835+ zipkin : true ,
836+ ..Default :: default ( )
837+ } ;
838+
839+ let builder = Builder :: new ( & None , & config) ;
840+ assert ! ( builder. build( ) . is_ok( ) ) ;
841+ assert ! ( tracing_test:: logs_contain(
842+ "if the datadog exporter is enabled and any other propagator except for baggage is enabled, the datadog propagator should be disabled to avoid trace id conflicts" ,
843+ ) ) ;
844+ }
845+
846+ #[ tokio:: test( flavor = "multi_thread" ) ]
847+ async fn test_datadog_exporter_enabled_with_datadog_aws_xray_propagation_fails ( ) {
848+ use crate :: test_harness:: tracing_test;
849+ let _guard = tracing_test:: dispatcher_guard ( ) ;
850+ let mut config = create_config_with_apollo_enabled ( ) ;
851+ config. exporters . tracing . datadog . enabled = true ;
852+ config. exporters . tracing . propagation = Propagation {
853+ datadog : Some ( true ) ,
854+ aws_xray : true ,
855+ ..Default :: default ( )
856+ } ;
857+
858+ let builder = Builder :: new ( & None , & config) ;
859+ assert ! ( builder. build( ) . is_ok( ) ) ;
860+ assert ! ( tracing_test:: logs_contain(
861+ "if the datadog exporter is enabled and any other propagator except for baggage is enabled, the datadog propagator should be disabled to avoid trace id conflicts" ,
862+ ) ) ;
863+ }
864+
865+ #[ tokio:: test( flavor = "multi_thread" ) ]
866+ async fn test_datadog_exporter_enabled_with_otlp_exporter_enabled_passes ( ) {
867+ let mut config = create_config_with_apollo_enabled ( ) ;
868+ config. exporters . tracing . datadog . enabled = true ;
869+ config. exporters . tracing . otlp . enabled = true ;
870+
871+ let builder = Builder :: new ( & None , & config) ;
872+ assert ! ( builder. build( ) . is_ok( ) ) ;
873+ }
874+
875+ #[ tokio:: test( flavor = "multi_thread" ) ]
876+ async fn test_datadog_propagation_with_otlp_exporter_enabled_passes ( ) {
877+ let mut config = create_config_with_apollo_enabled ( ) ;
878+ config. exporters . tracing . otlp . enabled = true ;
879+ config. exporters . tracing . propagation . datadog = Some ( true ) ;
880+
881+ let builder = Builder :: new ( & None , & config) ;
882+ assert ! ( builder. build( ) . is_ok( ) ) ;
883+ }
884+
885+ #[ tokio:: test( flavor = "multi_thread" ) ]
886+ async fn test_datadog_exporter_enabled_with_zipkin_exporter_enabled_fails ( ) {
887+ use crate :: test_harness:: tracing_test;
888+ let _guard = tracing_test:: dispatcher_guard ( ) ;
889+ let mut config = create_config_with_apollo_enabled ( ) ;
890+ config. exporters . tracing . datadog . enabled = true ;
891+ config. exporters . tracing . zipkin . enabled = true ;
892+
893+ let builder = Builder :: new ( & None , & config) ;
894+ assert ! ( builder. build( ) . is_ok( ) ) ;
895+ assert ! ( tracing_test:: logs_contain(
896+ "datadog propagation should be explicitly disabled if the datadog exporter is enabled and any propagator other than baggage is enabled to avoid trace id conflicts" ,
897+ ) ) ;
898+ }
629899}
0 commit comments