public void CompositePropagatorsProvider_GetPropagators()
        {
            var provider = new CompositePropagatorsProvider();

            provider.RegisterProvider(new ProviderStub(Propagator1));
            provider.RegisterProvider(new ProviderStub(Propagator3));

            var propagators = provider
                              .GetPropagators(new[] { Propagator1, Propagator3 }, null)
                              .Cast <PropagatorStub>()
                              .ToList();

            Assert.Equal(2, propagators.Count());
            Assert.Equal(Propagator1, propagators[0].Id);
            Assert.Equal(Propagator3, propagators[1].Id);
        }
        public void CompositePropagatorsProvider_GetPropagators_When_NoProvider()
        {
            var provider = new CompositePropagatorsProvider();

            provider.RegisterProvider(new ProviderStub(Propagator1));

            Assert.Throws <InvalidOperationException>(() => provider
                                                      .GetPropagators(new[] { Propagator2 }, null)
                                                      .Cast <PropagatorStub>()
                                                      .ToList());
        }
        private static CompositeTextMapPropagator CreateCompositePropagator(TracerSettings settings, ITraceIdConvention traceIdConvention, IReadOnlyCollection <IOTelExtension> extensions)
        {
            var compositeProvider = new CompositePropagatorsProvider();

            compositeProvider.RegisterProvider(new OTelPropagatorsProvider());

            foreach (var extension in extensions)
            {
                if (extension is IPropagatorsProvider provider)
                {
                    compositeProvider.RegisterProvider(provider);
                }
            }

            var propagators = compositeProvider
                              .GetPropagators(settings.Propagators, traceIdConvention)
                              .ToList();

            return(new CompositeTextMapPropagator(propagators));
        }